2019-01-03 16:00:55 +03:00
|
|
|
import React from 'react';
|
|
|
|
import Form from '@storybook/addon-knobs/dist/components/PropForm';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import { EVENT_ID_DATA, DEFAULT_THEME_STATE } from './constant';
|
|
|
|
import { listSchemes, listThemes } from '../../src/utils/theme';
|
|
|
|
|
|
|
|
const FormWrapper = styled.div`
|
|
|
|
width: 100%;
|
|
|
|
padding: 5px;
|
|
|
|
|
|
|
|
label {
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const schemes = listSchemes();
|
|
|
|
const themes = listThemes();
|
|
|
|
|
|
|
|
export default class Panel extends React.Component {
|
|
|
|
state = DEFAULT_THEME_STATE;
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
onChange = (o) => {
|
2019-01-03 16:00:55 +03:00
|
|
|
const state = { [o.name.split(' ').slice(-1)[0]]: o.value };
|
|
|
|
this.props.channel.emit(EVENT_ID_DATA, state);
|
|
|
|
this.setState(state);
|
|
|
|
};
|
|
|
|
|
2019-01-09 02:08:34 +03:00
|
|
|
onClick = () => {};
|
|
|
|
|
2019-01-03 16:00:55 +03:00
|
|
|
render() {
|
|
|
|
const { theme, scheme, light } = this.state;
|
|
|
|
return (
|
|
|
|
<FormWrapper>
|
|
|
|
<Form
|
|
|
|
knobs={[
|
|
|
|
{
|
|
|
|
type: 'select',
|
|
|
|
name: 'theme',
|
|
|
|
value: theme,
|
2020-08-08 23:26:39 +03:00
|
|
|
options: themes,
|
2019-01-03 16:00:55 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'select',
|
|
|
|
name: 'color scheme',
|
|
|
|
value: scheme,
|
2020-08-08 23:26:39 +03:00
|
|
|
options: schemes,
|
2019-01-03 16:00:55 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'boolean',
|
|
|
|
name: 'light',
|
2020-08-08 23:26:39 +03:00
|
|
|
value: light,
|
|
|
|
},
|
2019-01-03 16:00:55 +03:00
|
|
|
]}
|
|
|
|
onFieldChange={this.onChange}
|
2019-01-09 02:08:34 +03:00
|
|
|
onFieldClick={this.onClick}
|
2019-01-03 16:00:55 +03:00
|
|
|
/>
|
|
|
|
</FormWrapper>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|