Skip to content

Commit a94f17a

Browse files
committed
refactor(ui-view,ui-flex): add examples on how to override sharedTokens, fix docs console errors
1 parent d743c9c commit a94f17a

4 files changed

Lines changed: 79 additions & 18 deletions

File tree

docs/guides/upgrade-guide.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,17 @@ type: example
4242
---
4343
<InstUISettingsProvider
4444
theme={{
45-
themeOverrides: {
46-
canvas: {
47-
componentOverrides: {
48-
SharedTokens: {
49-
focusOutline: {
50-
infoColor: 'red',
51-
offset: '2rem'
52-
}
45+
newTheme: { // TODO remove this when we remove the old theme
46+
sharedTokens: {
47+
focusOutline: {
48+
infoColor: 'green',
49+
width: '0.4rem',
50+
offset: '0rem'
5351
}
5452
}
5553
}
56-
}
57-
}}>
58-
<TextInput renderLabel="Name" placeholder="Doe, John Doe"/>
54+
}}>
55+
<TextInput renderLabel="Name" placeholder="Note: Change example when the old theme is renamed!"/>
5956
</InstUISettingsProvider>
6057
```
6158

docs/guides/using-theme-overrides.md

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type: example
105105
</InstUISettingsProvider>
106106
```
107107

108-
### Overriding theme for a specific component in a subtree
108+
### Overriding theme for all components in a subtree
109109

110110
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.
111111

@@ -180,7 +180,7 @@ type: code
180180
</InstUISettingsProvider>
181181
```
182182

183-
#### Override function
183+
#### Override function for all instances
184184

185185
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.
186186

@@ -214,7 +214,7 @@ Themeable components (that implement the [withStyle](withStyle) decorator) accep
214214

215215
The available theme variables are always displayed at the bottom of the component's page (e.g.: [Button component theme variables](/#Button/#ButtonTheme)).
216216

217-
#### Override object
217+
#### Override object for a single component
218218

219219
```js
220220
---
@@ -256,7 +256,7 @@ type: example
256256
</div>
257257
```
258258

259-
#### Override function
259+
#### Override function for a single component
260260

261261
The override function's first parameter is the component's own theme object, the second is the main theme object.
262262

@@ -348,6 +348,68 @@ const generateStyle = (componentTheme) => {
348348
}
349349
```
350350
351+
### Theme overrides for focus rings, border radii, shadows, spacing
352+
353+
Certain visuals as of now styled via a central object called `SharedTokens`. You can override this too, for example:
354+
355+
```js
356+
---
357+
type: example
358+
---
359+
<InstUISettingsProvider
360+
theme={{
361+
newTheme: { // TODO remove this when we remove the old theme
362+
sharedTokens: {
363+
focusOutline: {
364+
infoColor: 'green',
365+
width: '0.4rem',
366+
offset: '0rem'
367+
},
368+
boxShadow: {
369+
// View shadows:
370+
// resting: elevation1,
371+
// above: elevation2,
372+
// topmost: elevation4
373+
elevation1: {
374+
"0": {
375+
color: 'blue',
376+
blur: '1rem',
377+
spread: '0.2rem'
378+
}
379+
}
380+
},
381+
spacing: {
382+
general: {
383+
space2xs: '2rem' // component margin/padding/Flex gap spacing
384+
}
385+
},
386+
legacy: {
387+
radiusSmall: '2rem', // View border radius
388+
},
389+
strokeWidth: {
390+
sm: '1rem' // View border width
391+
}
392+
},
393+
}
394+
}}>
395+
<TextInput renderLabel="Fancy focus ring!" placeholder="TODO: Change example when the old theme is renamed!"/>
396+
<View
397+
as="span"
398+
display="inline-block"
399+
maxWidth="15rem"
400+
margin="general.space2xs"
401+
padding="small"
402+
background="primary"
403+
shadow="resting"
404+
borderRadius="small"
405+
borderWidth="small"
406+
>
407+
Here is a View with a blue shadow. and custom borders
408+
</View>
409+
<Avatar name="Spacing Override" margin="general.space2xs" />
410+
</InstUISettingsProvider>
411+
```
412+
351413
### Branding (user customizable theming)
352414
353415
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 = () => {
492554

493555
<hr style={{width:'100%'}}/>
494556
<h3><code>SideNavBar</code> branding</h3>
495-
<Flex gap="large small">
557+
<Flex gap="small">
496558
<Flex.Item size="45%">
497559
<TextInput renderLabel="ic-brand-global-nav-bgd" value={icBrandGlobalNavBgd} onChange={(e, v) => setIcBrandGlobalNavBgd(v)}/>
498560
<TextInput renderLabel="ic-global-nav-link-hover" value={icGlobalNavLinkHover} onChange={(e, v) => setIcGlobalNavLinkHover(v)}/>

packages/ui-flex/src/Flex/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ class Flex extends Component<FlexProps> {
126126

127127
const gapValuesArray = gap?.split(' ')
128128
if (gapValuesArray!.length > 1 && wrap === 'no-wrap')
129-
console.warn('The `gap` prop is supplied with an improper `wrap` prop.')
129+
console.warn(
130+
'The `gap` prop is supplied with an improper `wrap=no-wrap` prop.'
131+
)
130132
if (children && Children.count(children) > 0) {
131133
return (
132134
<View

packages/ui-view/src/View/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ type: example
435435
</View>
436436
<View focusWithin>
437437
if the <code>focusWithin</code> prop is <code>true</code>, the View will display the focus ring if any of its descendants receives focus
438-
<div tabindex="0" role="button" style={{outline: 'none'}}>Tab here to see the focus outline</div>
438+
<div tabIndex="0" role="button" style={{outline: 'none'}}>Tab here to see the focus outline</div>
439439
</View>
440440
</Flex>
441441
```

0 commit comments

Comments
 (0)