-
Notifications
You must be signed in to change notification settings - Fork 107
refactor(ui-view,ui-flex): add examples on how to override sharedTokens, fix docs console errors #2382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v12
Are you sure you want to change the base?
refactor(ui-view,ui-flex): add examples on how to override sharedTokens, fix docs console errors #2382
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,7 +105,7 @@ type: example | |
| </InstUISettingsProvider> | ||
| ``` | ||
|
|
||
| ### Overriding theme for a specific component in a subtree | ||
| ### Overriding theme for all components in a subtree | ||
|
|
||
| You can override the theme variables of specific components too with the `componentOverrides` key. You can do this for every theme or for just a given theme. | ||
|
|
||
|
|
@@ -180,7 +180,7 @@ type: code | |
| </InstUISettingsProvider> | ||
| ``` | ||
|
|
||
| #### Override function | ||
| #### Override function for all instances | ||
|
|
||
| The `InstUISettingsProvider` accepts a `function`. The override function's first parameter is the currently applied theme object. It should return a valid theme or override object. | ||
|
|
||
|
|
@@ -214,7 +214,7 @@ Themeable components (that implement the [withStyle](withStyle) decorator) accep | |
|
|
||
| The available theme variables are always displayed at the bottom of the component's page (e.g.: [Button component theme variables](/#Button/#ButtonTheme)). | ||
|
|
||
| #### Override object | ||
| #### Override object for a single component | ||
|
|
||
| ```js | ||
| --- | ||
|
|
@@ -256,7 +256,7 @@ type: example | |
| </div> | ||
| ``` | ||
|
|
||
| #### Override function | ||
| #### Override function for a single component | ||
|
|
||
| The override function's first parameter is the component's own theme object, the second is the main theme object. | ||
|
|
||
|
|
@@ -348,6 +348,68 @@ const generateStyle = (componentTheme) => { | |
| } | ||
| ``` | ||
|
|
||
| ### Theme overrides for focus rings, border radii, shadows, spacing | ||
|
|
||
| Certain visuals as now styled via a central object called `SharedTokens`. You can override this too, for example: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a small grammatical thing: as OF now. At least I think so |
||
|
|
||
| ```js | ||
| --- | ||
| type: example | ||
| --- | ||
| <InstUISettingsProvider | ||
| theme={{ | ||
| newTheme: { // TODO remove this when we remove the old theme | ||
| sharedTokens: { | ||
| focusOutline: { | ||
| infoColor: 'green', | ||
| width: '0.4rem', | ||
| offset: '0rem' | ||
| }, | ||
| boxShadow: { | ||
| // View shadows: | ||
| // resting: elevation1, | ||
| // above: elevation2, | ||
| // topmost: elevation4 | ||
| elevation1: { | ||
| "0": { | ||
| color: 'blue', | ||
| blur: '1rem', | ||
| spread: '0.2rem' | ||
| } | ||
| } | ||
| }, | ||
| spacing: { | ||
| general: { | ||
| space2xs: '2rem' // component margin/padding/Flex gap spacing | ||
| } | ||
| }, | ||
| legacy: { | ||
| radiusSmall: '2rem', // View border radius | ||
| }, | ||
| strokeWidth: { | ||
| sm: '1rem' // View border width | ||
| } | ||
|
Comment on lines
+386
to
+391
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These will likely change, I just wanted to make sure that the current state works |
||
| }, | ||
| } | ||
| }}> | ||
| <TextInput renderLabel="Fancy focus ring!" placeholder="TODO: Change example when the old theme is renamed!"/> | ||
| <View | ||
| as="span" | ||
| display="inline-block" | ||
| maxWidth="15rem" | ||
| margin="general.space2xs" | ||
| padding="small" | ||
| background="primary" | ||
| shadow="resting" | ||
| borderRadius="small" | ||
| borderWidth="small" | ||
| > | ||
| Here is a View with a blue shadow. and custom borders | ||
| </View> | ||
| <Avatar name="Spacing Override" margin="general.space2xs" /> | ||
| </InstUISettingsProvider> | ||
| ``` | ||
|
|
||
| ### Branding (user customizable theming) | ||
|
|
||
| The `canvas` theme has specific theme variables that are meant as a basis to provide end users a customizability of this theme, e.g. a university can use their own colors throughout the UI. This is used by [Canvas's theme editor](https://community.canvaslms.com/t5/Admin-Guide/How-do-I-create-a-theme-for-an-account-using-the-Theme-Editor/ta-p/242). | ||
|
|
@@ -492,7 +554,7 @@ const Example = () => { | |
|
|
||
| <hr style={{width:'100%'}}/> | ||
| <h3><code>SideNavBar</code> branding</h3> | ||
| <Flex gap="large small"> | ||
| <Flex gap="small"> | ||
| <Flex.Item size="45%"> | ||
| <TextInput renderLabel="ic-brand-global-nav-bgd" value={icBrandGlobalNavBgd} onChange={(e, v) => setIcBrandGlobalNavBgd(v)}/> | ||
| <TextInput renderLabel="ic-global-nav-link-hover" value={icGlobalNavLinkHover} onChange={(e, v) => setIcGlobalNavLinkHover(v)}/> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -435,7 +435,7 @@ type: example | |
| </View> | ||
| <View focusWithin> | ||
| if the <code>focusWithin</code> prop is <code>true</code>, the View will display the focus ring if any of its descendants receives focus | ||
| <div tabindex="0" role="button" style={{outline: 'none'}}>Tab here to see the focus outline</div> | ||
| <div tabIndex="0" role="button" style={{outline: 'none'}}>Tab here to see the focus outline</div> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I shouldn't be capitalized in tabindex |
||
| </View> | ||
| </Flex> | ||
| ``` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are handled as array
keys, so if there is a duplicate like here React will emit an error