@newtonschool/grauity 3.3.3 → 3.3.4-beta.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/README.md CHANGED
@@ -163,18 +163,37 @@ Font files will be created in [ui/fonts](ui/fonts) folder.
163
163
 
164
164
  Without theming, only foundational (theme agnostic) CSS variables (found here: [constantGlobalStyle](ui/themes/GlobalStyle.ts)) will be provided.
165
165
 
166
+ ### GrauityThemeProvider
166
167
  To enable theming, wrap your components with `GrauityThemeProvider`:
167
168
 
168
169
  ```js
169
170
  import { GrauityThemeProvider } from '@newtonschool/grauity';
170
171
 
171
172
  const App = ({ children, ...props }) => {
172
- return <GrauityThemeProvider>{children}</GrauityThemeProvider>;
173
+ const [currentThemeName, setCurrentThemeName] = useState("light");
174
+
175
+ return (
176
+ <GrauityThemeProvider rootThemeScopeTheme={currentThemeName}>
177
+ {children}
178
+ </GrauityThemeProvider>
179
+ );
173
180
  };
174
181
 
175
182
  export default App;
176
183
  ```
177
184
 
185
+ Note: `rootThemeScopeTheme` (optional) should be set to your current global app theme name ("light" or "dark"). This is required to enable scoped themes using the NSThemeScope component.
186
+
187
+ ### NSThemeScope
188
+ Theming can be controlled by wrapping your elements with the NSThemeScope component, and providing props like `applyTheme` or `invert` and `as`.
189
+
190
+ - Use `applyTheme` to apply a hard-coded theme
191
+ - Use `invert` to invert the parent ThemeScope's theme
192
+ - Use the `as` prop and set it to your component's outermost element to avoid adding an extra `div` element
193
+
194
+ More details can be found on the [ThemeScope documentation page](https://grauity.newtonschool.co/?path=/docs/elements-themescope--docs).
195
+
196
+ ### Legacy (theme classes)
178
197
  Theming can be controlled by providing different class names to your root/local DOM elements, like the body element.
179
198
 
180
199
  - Add class `grauity-theme-light` to use the light theme
@@ -213,8 +232,9 @@ To use grauity icons, add the following import in `global-styles.scss` or any ro
213
232
  - Check the box for "Editor: Format On Save"
214
233
 
215
234
  Alternatively, you can add the following snippet to your `settings.json` file:
235
+
216
236
  ```json
217
237
  {
218
- "editor.formatOnSave": true
238
+ "editor.formatOnSave": true
219
239
  }
220
240
  ```