@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.
@@ -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
+ [![Code](https://img.shields.io/badge/GitHub-Code-232323.svg?logo=github&logoColor=white)](https://github.com/RoleModel/optics)
6
+
7
+ [![License](https://img.shields.io/badge/license-MIT-232323.svg)](https://github.com/RoleModel/optics/blob/main/LICENSE)
8
+
9
+ [![npm](https://img.shields.io/npm/dw/@rolemodel/optics?label=npm)](https://www.npmjs.com/package/@rolemodel/optics)
10
+
3
11
  [![Linting CI](https://github.com/RoleModel/optics/actions/workflows/linting.yml/badge.svg)](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