Skip to content

Commit 1904a0f

Browse files
committed
WIP(shared-types,ui-drilldown,ui-top-nav-bar): add lti colors
1 parent 5dc8f73 commit 1904a0f

File tree

15 files changed

+355
-234
lines changed

15 files changed

+355
-234
lines changed

packages/__docs__/src/App/index.tsx

Lines changed: 110 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/** @jsx jsx */
2626
import { Component } from 'react'
2727
import { Route, Routes, useNavigate } from 'react-router-dom'
28-
import { withStyle, jsx } from '@instructure/emotion'
28+
import { withStyle, jsx, InstUISettingsProvider } from '@instructure/emotion'
2929
import { CanvasTopNav, SubNav } from '@instructure/ui-top-nav-bar'
3030
import { IconButton } from '@instructure/ui-buttons'
3131
import {
@@ -40,6 +40,8 @@ import {
4040
import generateStyle from './styles'
4141
import generateComponentTheme from './theme'
4242
import { Img } from '@instructure/ui-img'
43+
import { Drilldown } from '@instructure/ui-drilldown'
44+
import { View } from '@instructure/ui-view'
4345

4446
type AppProps = {
4547
navigate: (path: string, options?: { replace: boolean }) => void
@@ -108,12 +110,13 @@ class App extends Component<AppProps, AppState> {
108110
const isLightMode = true
109111

110112
const brandSvg = (
111-
<IconButton
112-
screenReaderLabel="Canvas Brand"
113+
<View
113114
href="#"
114-
withBackground={false}
115-
withBorder={false}
116-
color={isLightMode ? 'secondary' : 'primary-inverse'}
115+
tabIndex={0}
116+
role="button"
117+
position="relative"
118+
borderRadius="small"
119+
focusColor="inverse" // LTI eseten nincs itt inverse, kek marad a focusring
117120
>
118121
<svg
119122
viewBox="0 0 1920 1920"
@@ -124,9 +127,81 @@ class App extends Component<AppProps, AppState> {
124127
>
125128
<path d="M958.568 277.97C1100.42 277.97 1216.48 171.94 1233.67 34.3881 1146.27 12.8955 1054.57 0 958.568 0 864.001 0 770.867 12.8955 683.464 34.3881 700.658 171.94 816.718 277.97 958.568 277.97ZM35.8207 682.031C173.373 699.225 279.403 815.285 279.403 957.136 279.403 1098.99 173.373 1215.05 35.8207 1232.24 12.8953 1144.84 1.43262 1051.7 1.43262 957.136 1.43262 862.569 12.8953 769.434 35.8207 682.031ZM528.713 957.142C528.713 1005.41 489.581 1044.55 441.31 1044.55 393.038 1044.55 353.907 1005.41 353.907 957.142 353.907 908.871 393.038 869.74 441.31 869.74 489.581 869.74 528.713 908.871 528.713 957.142ZM1642.03 957.136C1642.03 1098.99 1748.06 1215.05 1885.61 1232.24 1908.54 1144.84 1920 1051.7 1920 957.136 1920 862.569 1908.54 769.434 1885.61 682.031 1748.06 699.225 1642.03 815.285 1642.03 957.136ZM1567.51 957.142C1567.51 1005.41 1528.38 1044.55 1480.11 1044.55 1431.84 1044.55 1392.71 1005.41 1392.71 957.142 1392.71 908.871 1431.84 869.74 1480.11 869.74 1528.38 869.74 1567.51 908.871 1567.51 957.142ZM958.568 1640.6C816.718 1640.6 700.658 1746.63 683.464 1884.18 770.867 1907.11 864.001 1918.57 958.568 1918.57 1053.14 1918.57 1146.27 1907.11 1233.67 1884.18 1216.48 1746.63 1100.42 1640.6 958.568 1640.6ZM1045.98 1480.11C1045.98 1528.38 1006.85 1567.51 958.575 1567.51 910.304 1567.51 871.172 1528.38 871.172 1480.11 871.172 1431.84 910.304 1392.71 958.575 1392.71 1006.85 1392.71 1045.98 1431.84 1045.98 1480.11ZM1045.98 439.877C1045.98 488.148 1006.85 527.28 958.575 527.28 910.304 527.28 871.172 488.148 871.172 439.877 871.172 391.606 910.304 352.474 958.575 352.474 1006.85 352.474 1045.98 391.606 1045.98 439.877ZM1441.44 1439.99C1341.15 1540.29 1333.98 1697.91 1418.52 1806.8 1579 1712.23 1713.68 1577.55 1806.82 1418.5 1699.35 1332.53 1541.74 1339.7 1441.44 1439.99ZM1414.21 1325.37C1414.21 1373.64 1375.08 1412.77 1326.8 1412.77 1278.53 1412.77 1239.4 1373.64 1239.4 1325.37 1239.4 1277.1 1278.53 1237.97 1326.8 1237.97 1375.08 1237.97 1414.21 1277.1 1414.21 1325.37ZM478.577 477.145C578.875 376.846 586.039 219.234 501.502 110.339 341.024 204.906 206.338 339.592 113.203 498.637 220.666 584.607 378.278 576.01 478.577 477.145ZM679.155 590.32C679.155 638.591 640.024 677.723 591.752 677.723 543.481 677.723 504.349 638.591 504.349 590.32 504.349 542.048 543.481 502.917 591.752 502.917 640.024 502.917 679.155 542.048 679.155 590.32ZM1440 475.712C1540.3 576.01 1697.91 583.174 1806.8 498.637 1712.24 338.159 1577.55 203.473 1418.51 110.339 1332.54 217.801 1341.13 375.413 1440 475.712ZM1414.21 590.32C1414.21 638.591 1375.08 677.723 1326.8 677.723 1278.53 677.723 1239.4 638.591 1239.4 590.32 1239.4 542.048 1278.53 502.917 1326.8 502.917 1375.08 502.917 1414.21 542.048 1414.21 590.32ZM477.145 1438.58C376.846 1338.28 219.234 1331.12 110.339 1415.65 204.906 1576.13 339.593 1710.82 498.637 1805.39 584.607 1696.49 577.443 1538.88 477.145 1438.58ZM679.155 1325.37C679.155 1373.64 640.024 1412.77 591.752 1412.77 543.481 1412.77 504.349 1373.64 504.349 1325.37 504.349 1277.1 543.481 1237.97 591.752 1237.97 640.024 1237.97 679.155 1277.1 679.155 1325.37Z" />
126129
</svg>
127-
</IconButton>
130+
</View>
128131
)
129132

133+
const menuArray: any = [
134+
{
135+
id: 'default',
136+
options: [
137+
{
138+
id: 'account',
139+
label: 'Account',
140+
renderBeforeTitle: <IconUserLine />,
141+
subPageId: 'account'
142+
},
143+
{
144+
id: 'courses',
145+
label: 'Courses',
146+
renderBeforeTitle: <IconCoursesLine />,
147+
subPageId: 'courses'
148+
},
149+
{
150+
id: 'dashboard',
151+
label: 'Dashboard',
152+
renderBeforeTitle: <IconDashboardLine />,
153+
onClick: () => {
154+
this.props.navigate('/dashboard', { replace: true })
155+
window.location.reload()
156+
}
157+
},
158+
{
159+
id: 'help',
160+
label: 'Help',
161+
renderBeforeTitle: <IconQuestionLine />,
162+
onClick: () => alert('Help clicked')
163+
}
164+
]
165+
},
166+
{
167+
id: 'account',
168+
title: 'Account',
169+
renderBeforeMobileMenuItems: (
170+
<div style={{ display: 'flex', justifyContent: 'center' }}>
171+
<Img src="https://sbcf.fr/wp-content/uploads/2018/03/sbcf-default-avatar.png" />
172+
</div>
173+
),
174+
renderAfterMobileMenuItems: (
175+
<p>
176+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi
177+
aliquet erat in orci semper fringilla. Nullam suscipit mollis mi, at
178+
vehicula magna vulputate eu. Cras mattis felis id quam vehicula
179+
euismod. Nulla dolor enim, ornare in odio a, molestie dictum ligula.
180+
Nullam maximus et dolor eget porttitor. Vestibulum faucibus viverra
181+
pellentesque. Duis lorem lectus, porta vitae aliquam vitae, vehicula
182+
sagittis nulla. Aenean sagittis congue rhoncus. Cras laoreet eu
183+
nulla eu dignissim. Maecenas sed massa nisi. Suspendisse
184+
pellentesque, metus sed ultricies porta, justo tellus pulvinar diam,
185+
ac ornare massa nibh quis purus. Duis erat ipsum, pellentesque in
186+
diam non, luctus accumsan metus. In ipsum tellus, ullamcorper a
187+
faucibus a, venenatis ut urna. Sed at rutrum turpis.
188+
</p>
189+
),
190+
options: [
191+
{ id: 'accountinfo1', label: 'Account info 1' },
192+
{ id: 'accountinfo2', label: 'Account info 2' }
193+
]
194+
},
195+
{
196+
id: 'courses',
197+
title: 'Courses',
198+
options: [
199+
{ id: 'courses1', label: 'Courses1' },
200+
{ id: 'courses2', label: 'Courses2' }
201+
]
202+
}
203+
]
204+
130205
const menu: MenuCollection = {
131206
default: {
132207
items: [
@@ -149,9 +224,10 @@ class App extends Component<AppProps, AppState> {
149224
{
150225
label: 'Dashboard',
151226
renderBeforeLabel: <IconDashboardLine />,
152-
onClick: () => {
227+
onClick: (e) => {
228+
e.preventDefault()
153229
this.props.navigate('/dashboard', { replace: true })
154-
window.location.reload()
230+
// window.location.reload()
155231
}
156232
},
157233
{
@@ -228,7 +304,7 @@ class App extends Component<AppProps, AppState> {
228304
}
229305

230306
return (
231-
<div
307+
<InstUISettingsProvider
232308
style={{
233309
position: 'relative',
234310
width: '100%',
@@ -238,13 +314,13 @@ class App extends Component<AppProps, AppState> {
238314
>
239315
<CanvasTopNav
240316
brand={brandSvg}
241-
lightMode={false}
317+
lti={true}
242318
breadcrumb={{
243319
label: 'You are here:',
244320
links: [
245321
{ href: '#', label: 'Student Forecast' },
246322
{ href: '#', label: 'University of Utah' },
247-
{ href: '#', label: 'University of Colleges' }
323+
{ label: 'University of Colleges' }
248324
]
249325
}}
250326
hamburgerOnClick={() => alert('Hamburger clicked')}
@@ -261,31 +337,29 @@ class App extends Component<AppProps, AppState> {
261337
onClick: () => alert('Alerts clicked')
262338
}
263339
]}
264-
mobileMenuBackNavigation={menu[this.getCurrentMenu()]?.backNavigation}
265-
mobileMenu={menu[this.getCurrentMenu()].items}
266-
beforeMobileMenuItems={
267-
menu[this.getCurrentMenu()]?.renderBeforeMobileMenuItems
268-
}
269-
afterMobileMenuItems={
270-
menu[this.getCurrentMenu()]?.renderAfterMobileMenuItems
271-
}
272-
/>
273-
<SubNav
274-
menuItems={[
275-
{ title: 'Home', href: 'www.google.com', selected: true },
276-
{ title: 'Announcements', href: 'http://www.google.com' },
277-
{ title: 'Assignments', href: 'www.google.com' },
278-
{ title: 'Discussions', href: 'www.google.com' },
279-
{ title: 'Grades', href: 'www.google.com' },
280-
{ title: 'People', href: 'www.google.com' }
281-
]}
340+
mobileMenu={menuArray}
282341
/>
283-
284-
<Routes>
285-
{/*<Route path="/" element={<h1>This is home</h1>} />*/}
286-
<Route path="/dashboard" element={<h1>This is dashboard</h1>} />
287-
</Routes>
288-
</div>
342+
<div style={{ display: 'flex' }}>
343+
<SubNav
344+
menuItems={[
345+
{ title: 'Home', href: '/', selected: true },
346+
{ title: 'Account', href: '/account' },
347+
{ title: 'Courses', href: '/courses' },
348+
{
349+
title: 'Dashboard',
350+
onClick: () => this.props.navigate('/dashboard')
351+
},
352+
{ title: 'Help', onClick: () => alert('Help clicked') }
353+
]}
354+
/>
355+
<div style={{ padding: '30px' }}>
356+
<Routes>
357+
<Route path="/" element={<h1>This is home</h1>} />
358+
<Route path="/dashboard" element={<h1>This is dashboard</h1>} />
359+
</Routes>
360+
</div>
361+
</div>
362+
</InstUISettingsProvider>
289363
)
290364
}
291365
}

packages/shared-types/src/ComponentThemeVariables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ export type DrilldownTheme = {
561561
labelInfoPadding: Spacing['small']
562562
labelInfoColor: Colors['contrasts']['grey5782']
563563
borderColor: Colors['contrasts']['grey3045']
564+
headerTitleTextDecoration: string
564565
}
565566

566567
export type FileDropTheme = {

packages/ui-drilldown/src/Drilldown/DrilldownPage/props.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ type DrilldownPageOwnProps = {
8989
* Is the page disabled
9090
*/
9191
disabled?: boolean
92+
93+
renderBeforeChildren?: () => React.ReactNode
94+
95+
renderAfterChildren?: () => React.ReactNode
9296
}
9397

9498
type PropKeys = keyof DrilldownPageOwnProps
@@ -111,7 +115,9 @@ const propTypes: PropValidators<PropKeys> = {
111115
onHeaderActionClicked: PropTypes.func,
112116
onBackButtonClicked: PropTypes.func,
113117
withoutHeaderSeparator: PropTypes.bool,
114-
disabled: PropTypes.bool
118+
disabled: PropTypes.bool,
119+
renderBeforeChildren: PropTypes.func,
120+
renderAfterChildren: PropTypes.func
115121
}
116122

117123
const allowedProps: AllowedPropKeys = [
@@ -123,7 +129,9 @@ const allowedProps: AllowedPropKeys = [
123129
'onHeaderActionClicked',
124130
'onBackButtonClicked',
125131
'withoutHeaderSeparator',
126-
'disabled'
132+
'disabled',
133+
'renderBeforeChildren',
134+
'renderAfterChildren'
127135
]
128136

129137
export type { DrilldownPageProps, PageChildren }

packages/ui-drilldown/src/Drilldown/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,17 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
456456
<DrilldownOption
457457
id={this._headerBackId}
458458
onOptionClick={this.handleBackButtonClick}
459+
beforeLabelContentVAlign={'center'}
459460
>
460461
<div css={styles?.headerBack} role="presentation">
461462
{backButtonLabel}
462463
</div>
463464
</DrilldownOption>
464465
)
466+
467+
if (currentPage.renderBeforeChildren) {
468+
headerChildren.push(currentPage.renderBeforeChildren())
469+
}
465470
}
466471

467472
// Header title
@@ -965,7 +970,8 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
965970
lastItemWasSeparator = false
966971
return this.renderOption(child, getOptionProps, getDisabledOptionProps)
967972
} else {
968-
return null
973+
// eslint-disable-next-line react/jsx-key
974+
return <Options.Item>{child}</Options.Item>
969975
}
970976
})
971977
}
@@ -1437,6 +1443,11 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
14371443
>
14381444
<Options {...getListProps()} role="presentation" as={as}>
14391445
{this.renderList(getOptionProps, getDisabledOptionProps)}
1446+
{this.currentPage?.renderAfterChildren && (
1447+
<Options.Item>
1448+
{this.currentPage.renderAfterChildren()}
1449+
</Options.Item>
1450+
)}
14401451
</Options>
14411452
</View>
14421453
</View>

packages/ui-drilldown/src/Drilldown/styles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const generateStyle = (
5151
label: 'drilldown',
5252
overflow: 'visible', // needed for focus ring!
5353
borderColor: componentTheme.borderColor,
54-
54+
background: '#334451',
5555
...(hasHighlightedOption && {
5656
'&:focus::before': {
5757
display: 'none'
@@ -67,7 +67,8 @@ const generateStyle = (
6767
},
6868
headerTitle: {
6969
label: 'drilldown__headerTitle',
70-
fontWeight: componentTheme.headerTitleFontWeight
70+
fontWeight: componentTheme.headerTitleFontWeight,
71+
textDecoration: componentTheme.headerTitleTextDecoration
7172
},
7273
optionContainer: {
7374
label: 'drilldown__optionContainer',

packages/ui-drilldown/src/Drilldown/theme.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ const generateComponentTheme = (theme: Theme): DrilldownTheme => {
3838
headerActionColor: colors?.contrasts?.blue4570,
3939
labelInfoPadding: spacing?.small,
4040
labelInfoColor: colors?.contrasts?.grey5782,
41-
borderColor: colors?.contrasts?.grey3045
41+
borderColor: colors?.contrasts?.grey3045,
42+
headerTitleTextDecoration: 'none'
4243
}
4344

4445
return {

0 commit comments

Comments
 (0)