Skip to content

Commit e404545

Browse files
committed
Add input with action example
Add Select example
1 parent c8c1976 commit e404545

File tree

3 files changed

+61
-33
lines changed

3 files changed

+61
-33
lines changed

example/App.tsx

+8-28
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,14 @@ export default class App extends React.Component {
4747

4848
<Container style={{ marginTop: 24 }}>
4949
<Menu pointing secondary>
50-
<Menu.Item
51-
name="Form"
52-
active={selectedTab === 'Form'}
53-
onClick={this.handleChangeTab}
54-
/>
55-
56-
<Menu.Item
57-
name="Input"
58-
active={selectedTab === 'Input'}
59-
onClick={this.handleChangeTab}
60-
/>
61-
62-
<Menu.Item
63-
name="Checkbox"
64-
active={selectedTab === 'Checkbox'}
65-
onClick={this.handleChangeTab}
66-
/>
67-
68-
<Menu.Item
69-
name="RadioGroup"
70-
active={selectedTab === 'RadioGroup'}
71-
onClick={this.handleChangeTab}
72-
/>
73-
<Menu.Item
74-
name="Dropdown"
75-
active={selectedTab === 'Dropdown'}
76-
onClick={this.handleChangeTab}
77-
/>
50+
{Object.keys(tabs).map((key) => (
51+
<Menu.Item
52+
name={key}
53+
key={key}
54+
active={selectedTab === key}
55+
onClick={this.handleChangeTab}
56+
/>
57+
))}
7858
</Menu>
7959
{tabs[selectedTab]}
8060
</Container>

example/DropdownExamples.tsx

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Formsy from 'formsy-react';
22
import * as React from 'react';
33
import { Button, Container, Label, Message, Segment } from 'semantic-ui-react';
4-
import { Dropdown } from '../src';
4+
import { Dropdown, Select } from '../src';
55

66
const styles = {
77
root: {
@@ -101,6 +101,22 @@ export default class CheckboxExamples extends React.Component {
101101
/>
102102
);
103103

104+
const asSelect = (
105+
<Select
106+
name="as-select"
107+
id="as-select"
108+
options={options}
109+
required
110+
validationErrors={{
111+
isDefaultRequiredValue: 'You need to select a product',
112+
}}
113+
errorLabel={errorLabel}
114+
compact={true}
115+
basic={true}
116+
defaultValue={options[0].value}
117+
/>
118+
);
119+
104120
return (
105121
<Container style={styles.root}>
106122
<Formsy
@@ -109,15 +125,20 @@ export default class CheckboxExamples extends React.Component {
109125
ref={this.formRef}
110126
>
111127
<Segment>
112-
<h5> Single-select </h5>
128+
<h5>Single-select</h5>
113129
{dropdownSingle}
114130
</Segment>
115131

116132
<Segment>
117-
<h5> Single-select with default value </h5>
133+
<h5>Single-select with default value</h5>
118134
{singleSelectWithDefaultValue}
119135
</Segment>
120136

137+
<Segment>
138+
<h5>As Select</h5>
139+
{asSelect}
140+
</Segment>
141+
121142
<Segment>
122143
<h5> Multi-select (Four selections minimum)</h5>
123144
{dropdownMultiple}

example/InputExamples.tsx

+29-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Divider,
99
Message,
1010
} from 'semantic-ui-react';
11-
import { Input, Form } from '../src';
11+
import { Input, Select, Form } from '../src';
1212

1313
const styles = {
1414
root: {
@@ -100,6 +100,28 @@ export default class InputExamples extends React.Component {
100100
/>
101101
);
102102

103+
const inputWithAction = (
104+
<Input
105+
name="input-with-action"
106+
placeholder="Customer name"
107+
required={true}
108+
action={
109+
<Select
110+
basic
111+
compact
112+
name="title"
113+
as={({ children }) => <>{children}</>}
114+
options={[
115+
{ text: 'Mr', value: 'Mr' },
116+
{ text: 'Ms', value: 'Ms' },
117+
]}
118+
defaultValue="Mr"
119+
/>
120+
}
121+
actionPosition="left"
122+
/>
123+
);
124+
103125
return (
104126
<Container style={styles.root}>
105127
<Form onValidSubmit={this.onValidSubmit} ref={this.formRef}>
@@ -114,10 +136,15 @@ export default class InputExamples extends React.Component {
114136
</Segment>
115137

116138
<Segment>
117-
<h5> Input With Custorm Error Label </h5>
139+
<h5> Input With Custom Error Label </h5>
118140
{inputWithCustomErrorLabel}
119141
</Segment>
120142

143+
<Segment>
144+
<h5> Input With Action </h5>
145+
{inputWithAction}
146+
</Segment>
147+
121148
<Segment>
122149
<h5> Input With Default Value </h5>
123150
{inputWithDefaultValue}

0 commit comments

Comments
 (0)