-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
161 additions
and
81 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
js_modules/dagster-ui/packages/app-oss/src/InjectedComponents.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
js_modules/dagster-ui/packages/ui-components/src/components/RoundedButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import styled from 'styled-components'; | ||
|
||
import {Colors} from './Color'; | ||
import {IconWrapper} from './Icon'; | ||
|
||
export const RoundedButton = styled.button` | ||
background-color: ${Colors.navButton()}; | ||
border-radius: 24px; | ||
border: 0; | ||
color: ${Colors.navTextSelected()}; | ||
cursor: pointer; | ||
font-size: 14px; | ||
line-height: 20px; | ||
height: 32px; | ||
text-align: left; | ||
display: block; | ||
padding: 0 8px 0 4px; | ||
user-select: none; | ||
&:focus, | ||
&:active { | ||
outline: none; | ||
} | ||
${IconWrapper} { | ||
background: ${Colors.navText()}; | ||
} | ||
&:hover { | ||
background-color: ${Colors.navButtonHover()}; | ||
${IconWrapper} { | ||
background: ${Colors.navTextSelected()}; | ||
} | ||
} | ||
${IconWrapper} { | ||
transition: linear 100ms background; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
js_modules/dagster-ui/packages/ui-core/src/app/UserSettingsDialog/UserPreferences.oss.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { | ||
Box, | ||
Button, | ||
Checkbox, | ||
DAGSTER_THEME_KEY, | ||
DagsterTheme, | ||
Icon, | ||
Subheading, | ||
} from '@dagster-io/ui-components'; | ||
import React from 'react'; | ||
|
||
import {useStateWithStorage} from '../../hooks/useStateWithStorage'; | ||
import {SHORTCUTS_STORAGE_KEY} from '../ShortcutHandler'; | ||
import {HourCycleSelect} from '../time/HourCycleSelect'; | ||
import {ThemeSelect} from '../time/ThemeSelect'; | ||
import {TimezoneSelect} from '../time/TimezoneSelect'; | ||
import {automaticLabel} from '../time/browserTimezone'; | ||
|
||
export const UserPreferences = ({ | ||
onChangeRequiresReload, | ||
}: { | ||
onChangeRequiresReload: (requiresReload: boolean) => void; | ||
}) => { | ||
const [shortcutsEnabled, setShortcutsEnabled] = useStateWithStorage( | ||
SHORTCUTS_STORAGE_KEY, | ||
(value: any) => (typeof value === 'boolean' ? value : true), | ||
); | ||
|
||
const [theme, setTheme] = useStateWithStorage(DAGSTER_THEME_KEY, (value: any) => { | ||
if (value === DagsterTheme.Light || value === DagsterTheme.Dark) { | ||
return value; | ||
} | ||
return DagsterTheme.System; | ||
}); | ||
|
||
const initialShortcutsEnabled = React.useRef(shortcutsEnabled); | ||
const initialTheme = React.useRef(theme); | ||
|
||
const lastChangeValue = React.useRef(false); | ||
React.useEffect(() => { | ||
const didChange = | ||
initialTheme.current !== theme || initialShortcutsEnabled.current !== shortcutsEnabled; | ||
if (lastChangeValue.current !== didChange) { | ||
onChangeRequiresReload(didChange); | ||
lastChangeValue.current = didChange; | ||
} | ||
}, [shortcutsEnabled, theme, onChangeRequiresReload]); | ||
|
||
const trigger = React.useCallback( | ||
(timezone: string) => ( | ||
<Button | ||
rightIcon={<Icon name="arrow_drop_down" />} | ||
style={{minWidth: '200px', display: 'flex', justifyContent: 'space-between'}} | ||
> | ||
{timezone === 'Automatic' ? automaticLabel() : timezone} | ||
</Button> | ||
), | ||
[], | ||
); | ||
|
||
const toggleKeyboardShortcuts = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const {checked} = e.target; | ||
setShortcutsEnabled(checked); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box padding={{bottom: 4}}> | ||
<Subheading>Preferences</Subheading> | ||
</Box> | ||
<Box flex={{justifyContent: 'space-between', alignItems: 'center'}}> | ||
<div>Timezone</div> | ||
<TimezoneSelect trigger={trigger} /> | ||
</Box> | ||
<Box flex={{justifyContent: 'space-between', alignItems: 'center'}}> | ||
<div>Hour format</div> | ||
<HourCycleSelect /> | ||
</Box> | ||
<Box flex={{justifyContent: 'space-between', alignItems: 'center'}}> | ||
<div>Theme</div> | ||
<ThemeSelect theme={theme} onChange={setTheme} /> | ||
</Box> | ||
<Box padding={{vertical: 8}} flex={{justifyContent: 'space-between', alignItems: 'center'}}> | ||
<div>Enable keyboard shortcuts</div> | ||
<Checkbox checked={shortcutsEnabled} format="switch" onChange={toggleKeyboardShortcuts} /> | ||
</Box> | ||
</> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
js_modules/dagster-ui/packages/ui-core/src/app/UserSettingsDialog/UserPreferences.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {componentStub} from '../InjectedComponentContext'; | ||
|
||
export const UserPreferences = componentStub('UserPreferences'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters