@rolemodel/optics 0.4.2 → 0.5.0
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/NEW_COMPONENT.md +59 -0
- package/README.md +12 -0
- package/dist/css/optics.css +580 -221
- package/dist/css/optics.css.map +1 -1
- package/dist/scss/components/accordion.scss +1 -1
- package/dist/scss/components/avatar.scss +7 -6
- package/dist/scss/components/button.scss +1 -29
- package/dist/scss/components/card.scss +15 -5
- package/dist/scss/components/confirm-dialog.scss +7 -13
- package/dist/scss/components/form.scss +25 -2
- package/dist/scss/components/icon.scss +4 -1
- package/dist/scss/components/index.scss +6 -0
- package/dist/scss/components/modal.scss +16 -23
- package/dist/scss/components/navbar.scss +61 -0
- package/dist/scss/components/side_panel.scss +94 -0
- package/dist/scss/components/sidebar.scss +6 -6
- package/dist/scss/components/spinner.scss +55 -0
- package/dist/scss/components/switch.scss +106 -0
- package/dist/scss/components/tab.scss +84 -0
- package/dist/scss/components/table.scss +3 -3
- package/dist/scss/components/tag.scss +174 -0
- package/dist/scss/components/tooltip.scss +3 -3
- package/dist/scss/core/layout.scss +8 -1
- package/dist/scss/core/tokens/base_tokens.scss +56 -16
- package/dist/scss/core/tokens/dark_mode_tokens.scss +47 -42
- package/dist/scss/core/tokens/scale_color_tokens.scss +48 -51
- package/dist/scss/core/utilities.scss +15 -3
- package/dist/tokens/tokens.json +62 -2
- package/package.json +25 -24
package/NEW_COMPONENT.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Process for Creating New Code Components
|
|
2
|
+
|
|
3
|
+
To create a new CSS component, follow these steps:
|
|
4
|
+
|
|
5
|
+
1. Start by defining a Sass `%{component-name}-global` placeholder for the component. This placeholder will serve as the base style for the component and all its variants.
|
|
6
|
+
2. Extend the default class and all variants of the component with the global placeholder you defined in the previous step. This ensures that the base style is applied consistently across all variations.
|
|
7
|
+
3. When creating variants of the component, use the following syntax: `.{component-name}-{variant}`. Variants are top-level components that have distinct styles or functionalities.
|
|
8
|
+
4. For stylistic tweaks that apply to all variants, use modifiers following the BEM (Block, Element, Modifier) syntax. The modifier class should be in the format: `.{component-name}--{modifier}`.
|
|
9
|
+
|
|
10
|
+
<!-- TODO: This distintion should exist in the main docs as well, not just in the dev instructions. Understanding how to consume components in your app and know the distinctions here is a good idea. -->
|
|
11
|
+
|
|
12
|
+
## Variant vs. Modifier
|
|
13
|
+
|
|
14
|
+
A variant is a top-level component that has distinct styles or functionalities. For example, a button component can have a primary variant that has a different color and hover state than the default button. A modifier is a class that modifies the style of a component. For example, a button component can have a disabled modifier that changes the color and cursor of the button. Modifiers apply to all Variants.
|
|
15
|
+
|
|
16
|
+
To illustrate these concepts, let's consider an example of a button. You can use the following template as a guide:
|
|
17
|
+
|
|
18
|
+
```scss
|
|
19
|
+
// Define the global placeholder for the button component
|
|
20
|
+
%button-global {
|
|
21
|
+
// Base styles for the button
|
|
22
|
+
|
|
23
|
+
// Hover state
|
|
24
|
+
&:hover {
|
|
25
|
+
// Styles for the hovered button modifier
|
|
26
|
+
// ...
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Modifier: Large button
|
|
30
|
+
&.btn--large {
|
|
31
|
+
// Styles for the large button modifier
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Modifier: Disabled button
|
|
35
|
+
&.btn--disabled,
|
|
36
|
+
&:disabled {
|
|
37
|
+
// Styles for the disabled button modifier
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Default button class extending the global styles
|
|
42
|
+
.btn {
|
|
43
|
+
@extend %button-global;
|
|
44
|
+
// Specific styles for the default button variant
|
|
45
|
+
// ...
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Variant: Primary button
|
|
49
|
+
.btn-primary {
|
|
50
|
+
@extend %button-global;
|
|
51
|
+
// Specific styles for the primary button variant
|
|
52
|
+
// ...
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
By following this approach, you can easily create and manage CSS components with consistent styles and variations.
|
|
57
|
+
|
|
58
|
+
<!-- Future Instructions -->
|
|
59
|
+
<!-- # When and how to use a component API? -->
|
package/README.md
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
# Optics, a RoleModel Design System
|
|
2
2
|
|
|
3
|
+
<div style='display: flex; gap: 10px;'>
|
|
4
|
+
|
|
5
|
+
[](https://github.com/RoleModel/optics)
|
|
6
|
+
|
|
7
|
+
[](https://github.com/RoleModel/optics/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/@rolemodel/optics)
|
|
10
|
+
|
|
3
11
|
[](https://github.com/RoleModel/optics/actions/workflows/linting.yml)
|
|
4
12
|
|
|
13
|
+
</div>
|
|
14
|
+
|
|
5
15
|
Optics is an scss package that provides base styles and components that can be integrated and customized in a variety of projects.
|
|
6
16
|
|
|
7
17
|
## Installation
|
|
@@ -55,6 +65,8 @@ Add the following above a group to categorize the tokens.
|
|
|
55
65
|
|
|
56
66
|
### Component Documentation
|
|
57
67
|
|
|
68
|
+
For instructions on how to create a new component, see [Process for Creating New Components](./NEW_COMPONENT.MD)
|
|
69
|
+
|
|
58
70
|
Additional stories can be added using the following command, or copying an existing story.
|
|
59
71
|
|
|
60
72
|
```sh
|