@theroutingcompany/components 0.0.18-alpha.1 → 0.0.18-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/dist/trc-components.es.js +11405 -8959
- package/dist/trc-components.es.js.map +1 -1
- package/dist/trc-components.umd.js +896 -804
- package/dist/trc-components.umd.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +83 -82
- package/types/components/Box/Box.d.ts +133 -0
- package/types/components/Checkbox/Checkbox.d.ts +3 -1
- package/types/components/Dialog/Dialog.d.ts +4 -2
- package/types/components/Flex/Flex.d.ts +73 -0
- package/types/components/Page/Page.d.ts +15 -1
- package/types/components/index.d.ts +2 -0
- package/types/helpers/tokenUtils.d.ts +19 -0
package/README.md
CHANGED
|
@@ -182,12 +182,29 @@ Some reading material on this:
|
|
|
182
182
|
- [Why you should use HSL over other colour formats in your CSS.](https://sujansundareswaran.com/blog/why-hsl-is-better-than-hex-and-rgb)
|
|
183
183
|
- [Using HSL Colors In CSS](https://www.smashingmagazine.com/2021/07/hsl-colors-css/)
|
|
184
184
|
|
|
185
|
+
## Avoid adding margins by default to components
|
|
186
|
+
|
|
187
|
+
Avoid “leaky margins”. When possible, prefer a flex or grid container to space child items.
|
|
188
|
+
|
|
189
|
+
There are exceptions, eg a header or footer that is expected to always have some room below or above it.
|
|
190
|
+
|
|
191
|
+
<figure>
|
|
192
|
+
<blockquote>The trouble with confining styles to objects is that not everything should be considered a property of an object per se. Take margins: margins are something that exist between elements. Simply giving an element a top margin makes no sense, no matter how few or how many times you do it. <em>It’s like applying glue to one side of an object before you’ve determined whether you actually want to stick it to something or what that something might be.</em>
|
|
193
|
+
</blockquote>
|
|
194
|
+
<figcaption>
|
|
195
|
+
<cite>
|
|
196
|
+
<a href="https://alistapart.com/article/axiomatic-css-and-lobotomized-owls/#section5">Axiomatic CSS and Lobotomized Owls — Dispensing with margins
|
|
197
|
+
by Heydon Pickering</a>
|
|
198
|
+
</cite>
|
|
199
|
+
</figcaption>
|
|
200
|
+
</figure>
|
|
201
|
+
|
|
185
202
|
## Style variants
|
|
186
203
|
|
|
187
204
|
> **Warning**
|
|
188
205
|
> This is not settled and this pattern is not followed consistently (yet?).
|
|
189
206
|
|
|
190
|
-
Use CSS variables for the dynamic parts in styled-components using.
|
|
207
|
+
Use CSS variables for the dynamic parts in styled-components using.
|
|
191
208
|
|
|
192
209
|
See [The styled-components Happy Path](https://www.joshwcomeau.com/css/styled-components/)
|
|
193
210
|
|
|
@@ -257,14 +274,14 @@ The linting config is also quite strict with `@typescript-eslint`.
|
|
|
257
274
|
|
|
258
275
|
### Types of component props should be strong
|
|
259
276
|
|
|
260
|
-
Correct component types make it easier to use components without having to look at the source or example.
|
|
277
|
+
Correct component types make it easier to use components without having to look at the source or an example.
|
|
261
278
|
Exact types for props (for editor autocomplete) is a necessity, not a nice-to-have. Be as detailed as possible.
|
|
262
279
|
|
|
263
280
|
<figure>
|
|
264
281
|
<blockquote>
|
|
265
282
|
<ul>
|
|
266
283
|
<li>Avoid “stringly typed” code. Prefer more appropriate types where not every string is a possibility.</li>
|
|
267
|
-
<li>Prefer a union of string literal types to string if that more accurately describes the domain of a variable. You’ll get stricter type checking and improve the development experience.</li>
|
|
284
|
+
<li><em>Prefer a union of string literal types to string if that more accurately describes the domain of a variable. You’ll get stricter type checking and improve the development experience.</em></li>
|
|
268
285
|
</ul>
|
|
269
286
|
</blockquote>
|
|
270
287
|
<figcaption>
|
|
@@ -285,12 +302,13 @@ Exact types for props (for editor autocomplete) is a necessity, not a nice-to-ha
|
|
|
285
302
|
|
|
286
303
|
See [Avoiding JSX spread on foreign data prevents weird bugs sometimes.](https://www.gabe.pizza/notes-on-component-libraries/#avoiding-jsx-spread-on-foreign-data-prevents-weird-bugs-sometimes).
|
|
287
304
|
|
|
305
|
+
> I recommend, whenever possible, to destructure the props object and forward keys as needed. Breaking the props down removes excessive keys, allows setting defaults, and makes grepping the code easier.
|
|
306
|
+
|
|
288
307
|
Two ways we can solve this
|
|
289
308
|
|
|
290
309
|
1. Filter spread props. Reject all non-DOM props using a utility. Note react-aria has a util names `filterDOMProps` despite its name it does not filter DOM props (I think it's a legacy util).
|
|
291
310
|
2. Be more explicit. Write out all the props to forward and types explicitly.
|
|
292
311
|
|
|
293
|
-
> I recommend, whenever possible, to destructure the props object and forward keys as needed. Breaking the props down removes excessive keys, allows setting defaults, and makes grepping the code easier.
|
|
294
312
|
|
|
295
313
|
## Examples
|
|
296
314
|
|