Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(lsg): label for enum-item
Browse files Browse the repository at this point in the history
  • Loading branch information
Lasse Küchler committed Dec 11, 2017
1 parent 15397e1 commit 11213a6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/lsg/patterns/property-items/enum-item/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ export class BooleanItemDemo extends React.Component<{}, EnumItemDemoState> {
public constructor(props: {}) {
super(props);

const values = [
'Medium',
'Rare',
'Solid Shoe'
];
const values = ['Medium', 'Rare', 'Solid Shoe'];

this.state = {
values,
Expand All @@ -42,6 +38,7 @@ export class BooleanItemDemo extends React.Component<{}, EnumItemDemoState> {
<div>
<StyledDemo>
<EnumItem
label="Label"
values={this.state.values}
selectedValue={this.state.selectedItem}
handleChange={this.handleChange}
Expand Down
34 changes: 28 additions & 6 deletions src/lsg/patterns/property-items/enum-item/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
import { getSpace, Size } from '../../space/index';
import { fonts } from '../../fonts/index';
import { colors } from '../../colors/index';
import * as React from 'react';
import styled from 'styled-components';

export interface EnumItemProps {
label: string;
selectedValue: string;
values: string[];
className?: string;
handleChange?: React.ChangeEventHandler<HTMLSelectElement>;
}

const StyledEnumItem = styled.div`
width: 100%;
`;

const StyledLabel = styled.span`
display: block;
margin-bottom: ${getSpace(Size.XS)}px;
font-size: 14px;
font-family: ${fonts().NORMAL_FONT};
color: ${colors.grey70.toString()};
`;

export const EnumItem: React.StatelessComponent<EnumItemProps> = props => {
const { className, values, selectedValue, handleChange } = props;
const { className, values, selectedValue, handleChange, label } = props;

return (
<select className={className} onChange={handleChange} value={selectedValue}>
{values.map(value =>
<option value={value} key={value}>{value}</option>
)};
</select>
<StyledEnumItem className={className}>
<StyledLabel>{label}</StyledLabel>
<select className={className} onChange={handleChange} value={selectedValue}>
{values.map(value => (
<option value={value} key={value}>
{value}
</option>
))};
</select>
</StyledEnumItem>
);
};

Expand Down

0 comments on commit 11213a6

Please sign in to comment.