Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 5c75034

Browse files
committed
✨ Inline theme selection at onboarding
1 parent a833be9 commit 5c75034

File tree

2 files changed

+46
-10
lines changed

2 files changed

+46
-10
lines changed

stories/features/welcome/page/fakeLocale.ts

+5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ const locale = {
2525
fakeSearchProvider2: 'Google (default)',
2626
// fourth screen
2727
chooseYourTheme: 'Choose your color theme',
28+
selectTheme: 'Select a theme',
2829
findToolbarTheme: 'Set the color of your toolbar by selecting the light or dark option from the settings panel.',
30+
themeOption1: 'Dark',
31+
themeOption2: 'Light',
32+
themeOption3: 'Same as MacOS',
33+
2934
// fifth screen
3035
protectYourPrivacy: 'Manage your shields',
3136
adjustProtectionLevel: 'Protect against privacy-invading ads and trackers while browsing with Brave Shields. Set Shields to "down" if a site doesn’t seem to be working properly.',

stories/features/welcome/page/screens/themeBox.tsx

+41-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import * as React from 'react'
66

77
// Feature-specific components
8-
import { Content, Title, Paragraph, PrimaryButton } from '../../../../../src/features/welcome/'
8+
import { Content, Title, Paragraph, PrimaryButton, SelectGrid } from '../../../../../src/features/welcome/'
9+
import { SelectBox } from '../../../../../src/features/welcome'
910

1011
// Utils
1112
import locale from '../fakeLocale'
@@ -19,9 +20,30 @@ interface Props {
1920
onClick: () => void
2021
}
2122

22-
export default class ThemingBox extends React.PureComponent<Props, {}> {
23+
interface State {
24+
themeSelected: boolean
25+
}
26+
27+
export default class ThemingBox extends React.PureComponent<Props, State> {
28+
29+
constructor (props: Props) {
30+
super(props)
31+
this.state = {
32+
themeSelected: false
33+
}
34+
}
35+
36+
onClickSelectTheme = () => {
37+
this.props.onClick()
38+
}
39+
40+
onChangeThemeOption = (event: React.ChangeEvent<HTMLSelectElement>) => {
41+
this.setState({ themeSelected: event.target.value !== '' })
42+
}
43+
2344
render () {
24-
const { index, currentScreen, onClick } = this.props
45+
const { index, currentScreen } = this.props
46+
const { themeSelected } = this.state
2547
return (
2648
<Content
2749
zIndex={index}
@@ -32,13 +54,22 @@ export default class ThemingBox extends React.PureComponent<Props, {}> {
3254
<WelcomeThemeImage />
3355
<Title>{locale.chooseYourTheme}</Title>
3456
<Paragraph>{locale.findToolbarTheme}</Paragraph>
35-
<PrimaryButton
36-
level='primary'
37-
type='accent'
38-
size='large'
39-
text={locale.theme}
40-
onClick={onClick}
41-
/>
57+
<SelectGrid>
58+
<SelectBox onChange={this.onChangeThemeOption}>
59+
<option value=''>{locale.selectTheme}</option>
60+
<option value='Dark'>{locale.themeOption1}</option>
61+
<option value='Light'>{locale.themeOption2}</option>
62+
<option value='System'>{locale.themeOption3}</option>
63+
</SelectBox>
64+
<PrimaryButton
65+
level='primary'
66+
type='accent'
67+
size='large'
68+
text={locale.confirm}
69+
disabled={!themeSelected}
70+
onClick={this.onClickSelectTheme}
71+
/>
72+
</SelectGrid>
4273
</Content>
4374
)
4475
}

0 commit comments

Comments
 (0)