15 |
16 |
17 |
18 | ## General information
19 |
20 | For contributing with changes you must:
21 |
22 | 1. Fork Dev Links repository.
23 | 2. Make your changes and push them to the forked repository.
24 | 3. Create a Pull Request in Dev Links repository, expressing the changes you made. Your Pull Request will be reviewed for approval as soon as possible.
25 |
26 | You can contribute giving suggestions and notifying about any bug you have
27 | encountered.
28 |
29 | The project has the following structure:
30 |
31 | ```
32 | /
33 | ├── assets/
34 | │ └── icons/
35 | | ├── categories/ # all icons that appears next to category name
36 | | └── general/ # the rest of the icons used in the extension
37 | |
38 | ├── src/
39 | │ ├── components/ # All React components
40 | │ ├── context/ # react contexts
41 | | └── data/ # All static data about links and functions related to it
42 | | └── links/ # All links info seperated by category folders
43 | | ├── features/
44 | | └── tabs/
45 | |
46 | └── package.json
47 | ```
48 |
49 | ## Adding new link to a category
50 |
51 | For adding a link to a specific category you have to create a file like `/src/data/links/{category}/{link-name}.ts`.
52 | Where `category` is the existent category folder which your link belongs to, and `link-name` is a TypeScript
53 | file with the name of your link in lowercase and each word being seperated by `-` character.
54 |
55 | As example we will assume we are adding Google Fonts, that belongs to the fonts category. So, we have to create
56 | the link file `/src/data/links/fonts/google-fonts.ts` for Google Font's link.
57 | Inside that file you have to define and export an object representing the link.
58 |
59 | ```typescript
60 | // Import the link type from the index.ts which is inside
61 | // the font category folder. The type will vary
62 | // depending on the category you are adding to
63 | import type { FontsLink } from "./";
64 |
65 |
66 | const GoogleFontDescription =
67 | `
68 | Make your website more beautiful, fast and open through great typography.
69 | `;
70 |
71 | // Create the link object using the link type of the category.
72 | // Write the variable name using Pascal Case.
73 | const GoogleFonts: FontsLink = {
74 | name: 'Google Fonts',
75 | category: 'Fonts',
76 | linkUrl: 'https://fonts.google.com/',
77 | description: GoogleFontDescription,
78 | };
79 |
80 |
81 | export default GoogleFonts;
82 | ```
83 |
84 | A link object must have:
85 | 1. `name` written in the same way as their creators write it.
86 | 2. `category` its value will be enforced by the link type you imported.
87 | 3. `linkUrl` using the https protocol and with a slash at the end.
88 | 4. `description` give a short description of the link. You could mentions the features you could see in that link, but always try to keep it short. It should not be empty.
89 |
90 | The link variable name must match the link name deleting whitespaces as in the sample code. If it is not possible for syntax issues, you can use underscore characters. For example a variable name for the link `5 Seconds Of Summer`
91 | could be written as `_5SecondsOfSummer`.
92 |
93 | Now you have to add your new link object to the category object it belongs to. You can do this in the
94 | `/src/data/links/fonts/index.ts` file, which is placed inside the category folder.
95 |
96 | ```typescript
97 | import type { Link, LinkCategory, LinkCategoryName } from "..";
98 | import FontSpace from "./font-space";
99 | // Import the link object you just created
100 | import GoogleFonts from "./google-fonts";
101 |
102 |
103 | type FontsCategoryName = Extract;
104 |
105 |
106 | export type FontsLink = Omit & {
107 | category: FontsCategoryName
108 | };
109 |
110 |
111 | const fontsCategoryLinks: Array = [
112 | FontSpace,
113 | GoogleFonts, // Add your object in the array of links. Keep the alphabetical order
114 | ];
115 |
116 |
117 | const fontsCategory: LinkCategory = {
118 | name: 'Fonts',
119 | links: fontsCategoryLinks
120 | };
121 |
122 |
123 | export default fontsCategory;
124 | ```
125 |
126 |
127 | After doing all this, you can start the development server to see your new link being shown
128 | in 🚀 Dev Links. If you don't know how to do this, see the [Getting started with development in README.md](/README.md).
129 |
130 | ## Adding new category
131 |
132 | For adding a new category you have to add the category name in the
133 | `LinkCategoryName` type defined in `/src/data/links/index.ts`.
134 | This name will appear later, in the GUI, representing the category.
135 | Let's use as example that you wish to add `Images` category.
136 |
137 | ```typescript
138 | export type LinkCategoryName = 'Fonts' | 'Icons' | 'Images';
139 | ```
140 |
141 | The name must be put in alphabetical order inside `LinkCategoryName`.
142 |
143 | Now you must create a new category folder like `/src/data/links/images`.
144 | If the name of your category has more than one word use `-` for seperating
145 | the words.
146 |
147 | Inside the folder you just created, add an `index.ts` file. This file
148 | will be used for defining the category object for the new links,
149 | and will export it as default. In this file you will add code similar
150 | to this, but without the comments:
151 |
152 | ```typescript
153 | import type { Link, LinkCategory, LinkCategoryName } from "..";
154 |
155 |
156 | // Define the name type of the category
157 | // extracting 'Images' from LinkCategoryName
158 | type ImagesCategoryName = Extract;
159 |
160 |
161 | // Define the type for the links that will be added
162 | // to this new category
163 | export type ImagesLink = Omit & {
164 | category: ImagesCategoryName
165 | };
166 |
167 |
168 | // This array will contain all links that will be added
169 | // later to this new category
170 | const imagesCategoryLinks: Array = [];
171 |
172 |
173 | // Create the category object
174 | const imagesCategory: LinkCategory = {
175 | name: 'Images',
176 | links: imagesCategoryLinks
177 | };
178 |
179 | // And finally export as default the category object
180 | export default imagesCategory;
181 | ```
182 |
183 | Now that you have created a new category object you can import it
184 | to the list of category objects in `/src/data/links/index.ts` like this:
185 |
186 | ```typescript
187 | import fontsCategory from "./fonts";
188 | import iconsCategory from "./icons";
189 | // Import the category object you just created
190 | import imagesCategory from "./images";
191 |
192 | // You added the 'Images' category name some steps ago
193 | export type LinkCategoryName = 'Fonts' | 'Icons' | 'Images';
194 |
195 |
196 | export type LinkCategory = {
197 | name: LinkCategoryName;
198 | links: Array
199 | };
200 |
201 |
202 | export type Link = {
203 | name: string;
204 | category: LinkCategoryName;
205 | linkUrl: string;
206 | description: string;
207 | };
208 |
209 | // The objects must be in alphabetical order within the array
210 | const linksByCategory: Array = [
211 | fontsCategory,
212 | iconsCategory,
213 | imagesCategory, // add your category object
214 | ];
215 |
216 | export default linksByCategory;
217 | ```
218 |
219 | In the last part of this process you will have to add the icon that
220 | represents your new category. For that you have to add the icon
221 | in `.svg` format, this is for keeping Dev Links as lightweight
222 | as possible. The file name of the icon should match the name
223 | of the category folder you created.
224 | You will add the icon as `/assets/icons/categories/images.svg`.
225 | The icon must be `#652F9E` color and have outlined style, this is
226 | for keeping consistency with the other category icons.
227 |
228 | In the end you will have to add your icon in the `getIconForLinkCategory`
229 | function in `/src/data/category-icons.ts`:
230 |
231 | ```typescript
232 | import type { LinkCategoryName } from "./links";
233 | import FontsCategoryIcon from "data-base64:~assets/icons/categories/fonts.svg";
234 | import IconsCategoryIcon from "data-base64:~assets/icons/categories/icons.svg";
235 | import FavoriteIcon from "data-base64:~assets/icons/categories/favorite.svg";
236 | // Import your icon
237 | import ImagesCategoryIcon from "data-base64:~assets/icons/categories/images.svg";
238 |
239 |
240 | export const getIconForLinkCategory = (category: LinkCategoryName | 'Favorites') => {
241 |
242 | switch (category) {
243 |
244 | case 'Fonts':
245 | return FontsCategoryIcon;
246 |
247 | case 'Icons':
248 | return IconsCategoryIcon;
249 |
250 | // Add your category and icon in the switch-case
251 | case 'Images':
252 | return ImagesCategoryIcon;
253 |
254 | default:
255 | return FavoriteIcon;
256 | }
257 |
258 | };
259 | ```
260 |
261 | Now, your new category will appear in the GUI of 🚀 Dev Links .
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Rolando Rio Garaboa
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |