mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
REFACTOR knobs field to use field component
This commit is contained in:
parent
cc68e66c52
commit
d2faeb720f
@ -1,32 +1,15 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import styled from 'react-emotion';
|
||||
|
||||
import { Field } from '@storybook/components';
|
||||
import TypeMap from './types';
|
||||
|
||||
const InvalidType = () => <span>Invalid Type</span>;
|
||||
|
||||
const Field = styled('div')({
|
||||
display: 'table-row',
|
||||
padding: '5px',
|
||||
});
|
||||
const Label = styled('label')({
|
||||
display: 'table-cell',
|
||||
boxSizing: 'border-box',
|
||||
verticalAlign: 'top',
|
||||
paddingRight: 5,
|
||||
paddingTop: 5,
|
||||
textAlign: 'right',
|
||||
width: 80,
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
});
|
||||
|
||||
export default function PropField({ onChange, onClick, knob }) {
|
||||
const InputType = TypeMap[knob.type] || InvalidType;
|
||||
return (
|
||||
<Field>
|
||||
<Label htmlFor={knob.name}>{!knob.hideLabel && `${knob.name}`}</Label>
|
||||
<Field label={!knob.hideLabel && `${knob.name}`}>
|
||||
<InputType knob={knob} onChange={onChange} onClick={onClick} />
|
||||
</Field>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user