@newtonschool/grauity 1.3.8 → 2.0.0-beta.1

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.
Files changed (89) hide show
  1. package/README.md +71 -48
  2. package/dist/common/types.d.ts +20 -0
  3. package/dist/common/types.d.ts.map +1 -1
  4. package/dist/index.d.ts +2183 -53
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/main.cjs +1 -1
  7. package/dist/main.cjs.map +1 -1
  8. package/dist/module.mjs +1 -1
  9. package/dist/module.mjs.map +1 -1
  10. package/dist/ui/core/sizes/index.d.ts +1 -1
  11. package/dist/ui/core/sizes/index.d.ts.map +1 -1
  12. package/dist/ui/elements/Form/Checkbox/Checkbox.d.ts +8 -0
  13. package/dist/ui/elements/Form/Checkbox/Checkbox.d.ts.map +1 -0
  14. package/dist/ui/elements/Form/Checkbox/Checkbox.styles.d.ts +7 -0
  15. package/dist/ui/elements/Form/Checkbox/Checkbox.styles.d.ts.map +1 -0
  16. package/dist/ui/elements/Form/Checkbox/index.d.ts +3 -0
  17. package/dist/ui/elements/Form/Checkbox/index.d.ts.map +1 -0
  18. package/dist/ui/elements/Form/Checkbox/types.d.ts +72 -0
  19. package/dist/ui/elements/Form/Checkbox/types.d.ts.map +1 -0
  20. package/dist/ui/elements/Form/Checkbox/utils.d.ts +4 -0
  21. package/dist/ui/elements/Form/Checkbox/utils.d.ts.map +1 -0
  22. package/dist/ui/elements/Form/ErrorMessage/index.d.ts +4 -0
  23. package/dist/ui/elements/Form/ErrorMessage/index.d.ts.map +1 -0
  24. package/dist/ui/elements/Form/FormRow/FormRow.d.ts +9 -0
  25. package/dist/ui/elements/Form/FormRow/FormRow.d.ts.map +1 -0
  26. package/dist/ui/elements/Form/FormRow/index.d.ts +3 -0
  27. package/dist/ui/elements/Form/FormRow/index.d.ts.map +1 -0
  28. package/dist/ui/elements/Form/FormRow/index.styles.d.ts +3 -0
  29. package/dist/ui/elements/Form/FormRow/index.styles.d.ts.map +1 -0
  30. package/dist/ui/elements/Form/FormRow/types.d.ts +24 -0
  31. package/dist/ui/elements/Form/FormRow/types.d.ts.map +1 -0
  32. package/dist/ui/elements/Form/HelpMessage/index.d.ts +4 -0
  33. package/dist/ui/elements/Form/HelpMessage/index.d.ts.map +1 -0
  34. package/dist/ui/elements/Form/Label/index.d.ts +4 -0
  35. package/dist/ui/elements/Form/Label/index.d.ts.map +1 -0
  36. package/dist/ui/elements/Form/RadioButton/RadioButton.d.ts +4 -0
  37. package/dist/ui/elements/Form/RadioButton/RadioButton.d.ts.map +1 -0
  38. package/dist/ui/elements/Form/RadioButton/RadioButton.styles.d.ts +7 -0
  39. package/dist/ui/elements/Form/RadioButton/RadioButton.styles.d.ts.map +1 -0
  40. package/dist/ui/elements/Form/RadioButton/index.d.ts +3 -0
  41. package/dist/ui/elements/Form/RadioButton/index.d.ts.map +1 -0
  42. package/dist/ui/elements/Form/RadioButton/types.d.ts +67 -0
  43. package/dist/ui/elements/Form/RadioButton/types.d.ts.map +1 -0
  44. package/dist/ui/elements/Form/TextArea/TextArea.d.ts +4 -0
  45. package/dist/ui/elements/Form/TextArea/TextArea.d.ts.map +1 -0
  46. package/dist/ui/elements/Form/TextArea/constant.d.ts +13 -0
  47. package/dist/ui/elements/Form/TextArea/constant.d.ts.map +1 -0
  48. package/dist/ui/elements/Form/TextArea/index.d.ts +3 -0
  49. package/dist/ui/elements/Form/TextArea/index.d.ts.map +1 -0
  50. package/dist/ui/elements/Form/TextArea/index.styles.d.ts +4 -0
  51. package/dist/ui/elements/Form/TextArea/index.styles.d.ts.map +1 -0
  52. package/dist/ui/elements/Form/TextArea/types.d.ts +112 -0
  53. package/dist/ui/elements/Form/TextArea/types.d.ts.map +1 -0
  54. package/dist/ui/elements/Form/TextField/TextField.d.ts +4 -0
  55. package/dist/ui/elements/Form/TextField/TextField.d.ts.map +1 -0
  56. package/dist/ui/elements/Form/TextField/constants.d.ts +29 -0
  57. package/dist/ui/elements/Form/TextField/constants.d.ts.map +1 -0
  58. package/dist/ui/elements/Form/TextField/index.d.ts +3 -0
  59. package/dist/ui/elements/Form/TextField/index.d.ts.map +1 -0
  60. package/dist/ui/elements/Form/TextField/index.styles.d.ts +8 -0
  61. package/dist/ui/elements/Form/TextField/index.styles.d.ts.map +1 -0
  62. package/dist/ui/elements/Form/TextField/types.d.ts +122 -0
  63. package/dist/ui/elements/Form/TextField/types.d.ts.map +1 -0
  64. package/dist/ui/elements/Form/index.styles.d.ts +8 -0
  65. package/dist/ui/elements/Form/index.styles.d.ts.map +1 -0
  66. package/dist/ui/elements/Form/types.d.ts +31 -0
  67. package/dist/ui/elements/Form/types.d.ts.map +1 -0
  68. package/dist/ui/elements/Table/Table.d.ts +1 -1
  69. package/dist/ui/elements/Table/Table.d.ts.map +1 -1
  70. package/dist/ui/elements/Table/Table.styles.d.ts.map +1 -1
  71. package/dist/ui/elements/Table/types.d.ts +7 -0
  72. package/dist/ui/elements/Table/types.d.ts.map +1 -1
  73. package/dist/ui/elements/Tooltip/types.d.ts +3 -3
  74. package/dist/ui/elements/Tooltip/types.d.ts.map +1 -1
  75. package/dist/ui/index.d.ts +8 -0
  76. package/dist/ui/index.d.ts.map +1 -1
  77. package/dist/ui/themes/GlobalStyle.d.ts +7 -1
  78. package/dist/ui/themes/GlobalStyle.d.ts.map +1 -1
  79. package/dist/ui/themes/ThemeProvider.d.ts +878 -24
  80. package/dist/ui/themes/ThemeProvider.d.ts.map +1 -1
  81. package/dist/ui/themes/darkThemeConstants.d.ts +440 -13
  82. package/dist/ui/themes/darkThemeConstants.d.ts.map +1 -1
  83. package/dist/ui/themes/lightThemeConstants.d.ts +440 -13
  84. package/dist/ui/themes/lightThemeConstants.d.ts.map +1 -1
  85. package/dist/ui/themes/types.d.ts +11 -0
  86. package/dist/ui/themes/types.d.ts.map +1 -0
  87. package/dist/ui/themes/utils.d.ts +20 -0
  88. package/dist/ui/themes/utils.d.ts.map +1 -0
  89. package/package.json +1 -1
package/README.md CHANGED
@@ -26,7 +26,7 @@ Inspired by the natural laws that guide the cosmos, **gra.UI.ty** (pronounced "g
26
26
 
27
27
  ### Philosophy
28
28
 
29
- Like gravity itself, the principles of great design are universal, omnipresent, yet often unobserved. With gra.UI.ty, we aim to tap into these fundamental elements to craft UI components that not only look stunning but feel inherently right.
29
+ Like the gravitational force itself, the principles of great design are universal, omnipresent, yet often unobserved. With gra.UI.ty, we aim to tap into these fundamental elements to craft UI components that not only look stunning but feel inherently right.
30
30
 
31
31
  ### Component Naming Convention
32
32
 
@@ -37,53 +37,44 @@ For example, `NSButton`, `NSTable`, `NSInput`
37
37
 
38
38
  gra.UI.ty is also affectionately known as **grauity**, **graUIty** or simply as **gravity**
39
39
 
40
- ## Key Features
41
-
42
- - **Comprehensive Component Set:** From buttons and dialogs to complex data grids and sliders, gra.UI.ty has everything you need. (Coming soon!)
43
- - **Semantic and Mindful Components:** Our components are more than just divs. Each one is thoughtfully designed with semantic HTML for better accessibility and SEO. We aim to ensure that each component has a clear and meaningful structure.
44
- - **Modular and Extensible:** Integrate seamlessly with your projects, adding only what you need without bloating your codebase.
45
- - **Theming and Customization:** Easily adapt the components to match your brand or project’s aesthetic. (Coming soon!)
46
- - **Accessibility First:** Built with accessibility in mind, ensuring that your applications are usable by everyone. (We'll get there...)
47
-
48
40
  ## Setup gra.UI.ty to make it your own!
49
41
 
50
42
  ### Developing Components
51
43
 
52
- To develop components gra.UI.ty locally, follow these steps:
44
+ To start your development journey in grauity, follow these steps:
53
45
 
54
46
  ```bash
55
- # Install all packages via NPM in grauity
56
- grauity$: npm install
47
+ # Install all packages in grauity
48
+ npm install
57
49
 
58
- # Initialize submodules for iconland
59
- grauity$: git submodule init
60
- grauity$: git submodule update --recursive
50
+ # Update submodules (mainly iconland, the submodule for icons)
51
+ git submodule init
52
+ git submodule update --recursive
61
53
 
62
- # Build icons when running for first time
63
- grauity$: npm run build-icons
54
+ # Build icons (required when running for first time)
55
+ npm run build-icons
64
56
 
65
- # To run storybook, run this command in grauity
66
- grauity$: npm run storybook
57
+ # Run grauity Storybook
58
+ npm run storybook
67
59
  # Then head to localhost:6006
68
60
 
69
- # To build storybook, run this command in grauity
70
- grauity$: npm run build-storybook
61
+ # To build grauity Storybook docs, run this command in grauity
62
+ npm run build-storybook
71
63
  ```
72
64
 
73
- ### Integrating locally with newton-web
65
+ ### Integrating locally with your app for side-by-side development & testing
74
66
 
75
- To integrate grauity locally with newton-web, follow these steps:
67
+ To integrate grauity locally with your app, follow these steps:
76
68
 
77
69
  ```bash
78
- # Firstly, install all packages via NPM in grauity
70
+ # Install all packages in grauity
79
71
  grauity$: npm install
80
72
 
81
- # To build grauity, run this command
73
+ # Build grauity
82
74
  grauity$: npm run build
83
75
 
84
- # Then, run these commands in newton-web:
85
- newton-web$: npm install ../grauity
86
- # This is assuming `grauity` and `newton-web` share same parent folder
76
+ # Install local version of grauity
77
+ your-app$: npm install ../grauity
87
78
 
88
79
  # Now, link react, react-dom from grauity to newton-web:
89
80
  newton-web$: npm link ../grauity/node_modules/react ../grauity/node_modules/react-dom --legacy-peer-deps
@@ -93,21 +84,20 @@ newton-web$: npm run dev
93
84
  ```
94
85
 
95
86
  After you have made changes in grauity, build it.
96
-
97
87
  ```bash
98
88
  grauity$: npm run build
99
89
  ```
100
90
 
101
91
  If changes are not showing up even after rebuilding, you may
102
- have to delete `newton-web/node_modules/@newtonschool/grauity`
103
- and install it again using
104
-
92
+ have to delete `your-app/node_modules/@newtonschool/grauity` folder
93
+ and install `grauity` again:
105
94
  ```bash
106
- newton-web$: npm i ../grauity --legacy-peer-deps
107
- newton-web$: npm run dev
95
+ grauity$: npm run build
96
+
97
+ your-app$: npm install ../grauity
108
98
  ```
109
99
 
110
- Then simply import components you want from `@newtonschool/grauity` in `newton-web` like so:
100
+ Then simply import components you want from `@newtonschool/grauity` in `your-app` like so:
111
101
 
112
102
  ```js
113
103
  import { NSButton, BUTTON_VARIANTS_ENUM } from '@newtonschool/grauity';
@@ -130,37 +120,70 @@ export const MyComponent = () => (
130
120
  );
131
121
  ```
132
122
 
133
- ## How to's
134
123
 
135
- ### Add icons
124
+ # How to's
136
125
 
137
- Adding new icons is easy. Design team to provide `.svg` files for new icons, and they are to be added to the [./iconland/seeds/](iconland/seeds) directory. Then follow these steps:
126
+ ## Add new icons from `.svg` files
138
127
 
139
- ### 0. Update the iconland submodule in grauity
128
+ ### 1. Update the iconland submodule in grauity
140
129
 
141
130
  ```bash
142
131
  grauity$: git submodule update --remote --merge
143
132
  ```
144
133
 
145
- #### 1. Generate icons
134
+ ### 2. Add your `.svg` files
146
135
 
147
- ```bash
148
- grauity$: npm run build-icons:generate
149
- ```
136
+ To add a new font icon, add your `.svg` files for the new icon in the [./iconland/seeds/](iconland/seeds) directory in the [iconland](./iconland) submodule.
150
137
 
151
- #### 2. Optimise icons (from [[iconland/seeds/]](iconland/seeds/) to [iconland/optimised/](iconland/optimised/) )
138
+
139
+ #### 3. Optimize & Generate new font files
152
140
 
153
141
  ```bash
154
142
  grauity$: npm run build-icons:optimize
143
+ grauity$: npm run build-icons:generate
155
144
  ```
156
-
157
- #### 3. Build font icons from optimised icons
158
-
145
+ *Alternatively*, run the command
159
146
  ```bash
160
147
  grauity$: npm run build-icons
161
148
  ```
162
149
 
163
- ### Use icons in newton-web
150
+ Font files will be created in [ui/fonts](ui/fonts) folder.
151
+
152
+
153
+ ## Use theming in your React app
154
+
155
+ Without theming, only foundational (theme agnostic) CSS variables (found here: [constantGlobalStyle](ui/themes/GlobalStyle.ts)) will be provided.
156
+
157
+ To enable theming, wrap your components with `GrauityThemeProvider`:
158
+ ```js
159
+ import { GrauityThemeProvider } from '@newtonschool/grauity';
160
+
161
+ const App = ({ children, ...props }) => {
162
+ return (
163
+ <GrauityThemeProvider>
164
+ {children}
165
+ </GrauityThemeProvider>
166
+ )
167
+ };
168
+
169
+ export default App;
170
+ ```
171
+
172
+
173
+ Theming can be controlled by providing different class names to your root/local DOM elements, like the body element.
174
+
175
+ - Add class `grauity-theme-light` to use the light theme
176
+ - Add class `grauity-theme-dark` to use the dark theme
177
+
178
+ Now, you will be provided with the foundational as well as themed CSS variables, whose
179
+ value will change depending on the theme applied.
180
+
181
+ These themed CSS variables can be found here:
182
+ - [Dark theme color mapping](./ui/themes/darkThemeConstants.ts)
183
+ - [Light theme color mapping](./ui/themes/lightThemeConstants.ts)
184
+
185
+
186
+ ## Use icons in your React app
164
187
 
165
188
  To use grauity icons, add the following import in `global-styles.scss` or any root-level CSS/SCSS file. Make sure CSS/SCSS loaders are setup properly in your app.
166
189
 
@@ -27,6 +27,17 @@ export interface StyledSelectProps extends React.SelectHTMLAttributes<HTMLSelect
27
27
  export interface StyledInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
28
28
  ref?: React.Ref<HTMLInputElement>;
29
29
  }
30
+ /**
31
+ * Interface representing the properties for a styled label component.
32
+ *
33
+ * @extends React.LabelHTMLAttributes<HTMLLabelElement>
34
+ * @property {React.Ref<HTMLLabelElement>} [ref] - Optional ref to the label element.
35
+ */
36
+ export interface StyledLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
37
+ ref?: React.Ref<HTMLLabelElement>;
38
+ isRequired?: boolean;
39
+ isDisabled?: boolean;
40
+ }
30
41
  /**
31
42
  * Interface representing the properties for a styled button component.
32
43
  *
@@ -36,4 +47,13 @@ export interface StyledInputProps extends React.InputHTMLAttributes<HTMLInputEle
36
47
  export interface StyledButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
37
48
  ref?: React.Ref<HTMLButtonElement>;
38
49
  }
50
+ /**
51
+ * Interface representing the properties for a styled text area component.
52
+ *
53
+ * @extends React.TextareaHTMLAttributes<HTMLTextAreaElement>
54
+ * @property {React.Ref<HTMLTextAreaElement>} [ref] - Optional ref to the text area element.
55
+ */
56
+ export interface StyledTextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
57
+ ref?: React.Ref<HTMLTextAreaElement>;
58
+ }
39
59
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACxE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBACb,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBACb,SAAQ,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC;IACnD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;CACrC;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBACb,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACtC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACxE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBACb,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBACb,SAAQ,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC;IACnD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;CACrC;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBACb,SAAQ,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC;IACnD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBACb,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBACb,SAAQ,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC;IACzD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;CACxC"}