-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement a button to switch between new and old UI
- Loading branch information
Showing
17 changed files
with
324 additions
and
38 deletions.
There are no files selected for viewing
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,8 @@ | ||
export enum LocalStorageKey { | ||
UIMode = 'ui-mode' | ||
} | ||
|
||
export enum UiMode { | ||
Old = 'old', | ||
New = 'new', | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,50 @@ | ||
import React, {Component} from 'react'; | ||
import {Flask} from '@gravity-ui/icons'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {connect} from 'react-redux'; | ||
import {Label} from '@gravity-ui/uikit'; | ||
import {Button, Icon, Label} from '@gravity-ui/uikit'; | ||
import {isEmpty} from 'lodash'; | ||
import {version} from '../../../../package.json'; | ||
import useLocalStorage from '@/static/hooks/useLocalStorage'; | ||
import {LocalStorageKey, UiMode} from '@/constants/local-storage'; | ||
|
||
class ReportInfo extends Component { | ||
static propTypes = { | ||
gui: PropTypes.bool.isRequired, | ||
timestamp: PropTypes.number.isRequired | ||
}; | ||
function ReportInfo(props) { | ||
const {gui, timestamp} = props; | ||
const lang = isEmpty(navigator.languages) ? navigator.language : navigator.languages[0]; | ||
const date = new Date(timestamp).toLocaleString(lang); | ||
|
||
const [, setUiMode] = useLocalStorage(LocalStorageKey.UIMode, UiMode.New); | ||
|
||
render() { | ||
const {gui, timestamp} = this.props; | ||
const lang = isEmpty(navigator.languages) ? navigator.language : navigator.languages[0]; | ||
const date = new Date(timestamp).toLocaleString(lang); | ||
const onNewUiButtonClick = () => { | ||
setUiMode(UiMode.New); | ||
|
||
return ( | ||
<div className="report-info"> | ||
<Label qa='version-label' size='m' className='label'> | ||
Version | ||
<div className='detail'>{version}</div> | ||
</Label> | ||
{!gui && <Label qa='created-at-label' size='m' className='label'> | ||
Created at | ||
<div className='detail'>{date}</div> | ||
</Label>} | ||
</div> | ||
); | ||
} | ||
if (window.location.pathname.endsWith('.html')) { | ||
window.location.href = '/new-ui.html'; | ||
} else { | ||
window.location.href = '/new-ui'; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="report-info"> | ||
<Button className={'new-ui-button'} onClick={onNewUiButtonClick}><div className='new-ui-button__glow'></div><Icon data={Flask}/>Try New UI</Button> | ||
<Label qa='version-label' size='m' className='label'> | ||
Version | ||
<div className='detail'>{version}</div> | ||
</Label> | ||
{!gui && <Label qa='created-at-label' size='m' className='label'> | ||
Created at | ||
<div className='detail'>{date}</div> | ||
</Label>} | ||
</div> | ||
); | ||
} | ||
|
||
ReportInfo.propTypes = { | ||
gui: PropTypes.bool.isRequired, | ||
timestamp: PropTypes.number.isRequired | ||
}; | ||
|
||
export default connect( | ||
({gui, timestamp}) => ({gui, timestamp}) | ||
)(ReportInfo); |
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
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
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
32 changes: 32 additions & 0 deletions
32
lib/static/new-ui/components/SettingsPanel/index.module.css
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,32 @@ | ||
.container { | ||
background-color: #fff; | ||
padding: 20px; | ||
width: 440px; | ||
height: 100%; | ||
|
||
--g-text-body-font-weight: 450; | ||
--g-text-body-short-font-size: 15px; | ||
} | ||
|
||
.separator { | ||
height: 1px; | ||
background-color: var(--g-color-private-black-50); | ||
margin: 20px 0; | ||
} | ||
|
||
.separator:first-of-type { | ||
margin-top: 12px; | ||
} | ||
|
||
.setting-title { | ||
|
||
} | ||
|
||
.setting-subtitle { | ||
color: var(--g-color-private-black-400); | ||
margin-top: 4px; | ||
} | ||
|
||
.setting-control { | ||
margin-top: 16px; | ||
} |
Oops, something went wrong.