aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/forms/src/button/index.tsx8
-rw-r--r--packages/forms/src/input/index.tsx4
-rw-r--r--packages/forms/src/typings/generic.ts1
-rw-r--r--packages/forms/src/wrapper/index.tsx9
-rw-r--r--packages/forms/src/wrapper/styles.ts5
-rw-r--r--uidev/src/app.tsx2
-rw-r--r--uidev/src/stories/button.stories.tsx40
7 files changed, 53 insertions, 16 deletions
diff --git a/packages/forms/src/button/index.tsx b/packages/forms/src/button/index.tsx
index 6959cde73..9faedc8f1 100644
--- a/packages/forms/src/button/index.tsx
+++ b/packages/forms/src/button/index.tsx
@@ -44,7 +44,7 @@ const styles = (theme: Theme) => ({
44 width: (props: IProps) => (props.stretch ? '100%' : 'auto') as CSS.WidthProperty<string>, 44 width: (props: IProps) => (props.stretch ? '100%' : 'auto') as CSS.WidthProperty<string>,
45 fontSize: theme.uiFontSize, 45 fontSize: theme.uiFontSize,
46 textDecoration: 'none', 46 textDecoration: 'none',
47 height: theme.buttonHeight, 47 // height: theme.buttonHeight,
48 48
49 '&:hover': { 49 '&:hover': {
50 opacity: 0.8, 50 opacity: 0.8,
@@ -129,8 +129,7 @@ const styles = (theme: Theme) => ({
129 position: (props: IProps): CSS.PositionProperty => props.stretch ? 'absolute' : 'inherit', 129 position: (props: IProps): CSS.PositionProperty => props.stretch ? 'absolute' : 'inherit',
130 }, 130 },
131 icon: { 131 icon: {
132 marginLeft: -5, 132 margin: [1, 10, 0, -5],
133 marginRight: 10,
134 }, 133 },
135}); 134});
136 135
@@ -142,7 +141,6 @@ class ButtonComponent extends Component<IProps> {
142 buttonType: 'primary' as ButtonType, 141 buttonType: 'primary' as ButtonType,
143 stretch: false, 142 stretch: false,
144 busy: false, 143 busy: false,
145 // target: '_self'
146 }; 144 };
147 145
148 state = { 146 state = {
@@ -220,7 +218,7 @@ class ButtonComponent extends Component<IProps> {
220 {icon && ( 218 {icon && (
221 <Icon 219 <Icon
222 path={icon} 220 path={icon}
223 size={1} 221 size={0.8}
224 className={classes.icon} 222 className={classes.icon}
225 /> 223 />
226 )} 224 )}
diff --git a/packages/forms/src/input/index.tsx b/packages/forms/src/input/index.tsx
index a2d7c62d5..b96dbc12d 100644
--- a/packages/forms/src/input/index.tsx
+++ b/packages/forms/src/input/index.tsx
@@ -83,7 +83,7 @@ class InputComponent extends Component<IProps, IState> {
83 } 83 }
84 84
85 onInputKeyPress(e: React.KeyboardEvent) { 85 onInputKeyPress(e: React.KeyboardEvent) {
86 if (e.key === "Enter") { 86 if (e.key === 'Enter') {
87 const { onEnterKey } = this.props; 87 const { onEnterKey } = this.props;
88 onEnterKey && onEnterKey(); 88 onEnterKey && onEnterKey();
89 } 89 }
@@ -114,6 +114,7 @@ class InputComponent extends Component<IProps, IState> {
114 max, 114 max,
115 step, 115 step,
116 required, 116 required,
117 noMargin,
117 } = this.props; 118 } = this.props;
118 119
119 const { 120 const {
@@ -127,6 +128,7 @@ class InputComponent extends Component<IProps, IState> {
127 <Wrapper 128 <Wrapper
128 className={className} 129 className={className}
129 identifier="franz-input" 130 identifier="franz-input"
131 noMargin={noMargin}
130 > 132 >
131 <Label 133 <Label
132 title={label} 134 title={label}
diff --git a/packages/forms/src/typings/generic.ts b/packages/forms/src/typings/generic.ts
index 9688ce2c7..29136dfed 100644
--- a/packages/forms/src/typings/generic.ts
+++ b/packages/forms/src/typings/generic.ts
@@ -6,6 +6,7 @@ export interface IFormField {
6 label?: string; 6 label?: string;
7 error?: string; 7 error?: string;
8 required?: boolean; 8 required?: boolean;
9 noMargin?: boolean;
9} 10}
10 11
11export interface IWithStyle { 12export interface IWithStyle {
diff --git a/packages/forms/src/wrapper/index.tsx b/packages/forms/src/wrapper/index.tsx
index d9c61381d..cf179bc5e 100644
--- a/packages/forms/src/wrapper/index.tsx
+++ b/packages/forms/src/wrapper/index.tsx
@@ -3,14 +3,19 @@ import React, { Component } from 'react';
3import injectStyle from 'react-jss'; 3import injectStyle from 'react-jss';
4import { IWithStyle } from '../typings/generic'; 4import { IWithStyle } from '../typings/generic';
5 5
6import styles from './styles';
7
8interface IProps extends IWithStyle { 6interface IProps extends IWithStyle {
9 children: React.ReactNode; 7 children: React.ReactNode;
10 className?: string; 8 className?: string;
11 identifier: string; 9 identifier: string;
10 noMargin?: boolean;
12} 11}
13 12
13const styles = {
14 container: {
15 marginBottom: (props: IProps) => props.noMargin ? 0 : 20,
16 },
17};
18
14class WrapperComponent extends Component<IProps> { 19class WrapperComponent extends Component<IProps> {
15 render() { 20 render() {
16 const { 21 const {
diff --git a/packages/forms/src/wrapper/styles.ts b/packages/forms/src/wrapper/styles.ts
deleted file mode 100644
index 72306b252..000000000
--- a/packages/forms/src/wrapper/styles.ts
+++ /dev/null
@@ -1,5 +0,0 @@
1export default {
2 container: {
3 marginBottom: 20,
4 },
5};
diff --git a/uidev/src/app.tsx b/uidev/src/app.tsx
index 870911c2f..cef22e7a7 100644
--- a/uidev/src/app.tsx
+++ b/uidev/src/app.tsx
@@ -2,7 +2,7 @@ import CSS from 'csstype';
2import { Classes } from 'jss'; 2import { Classes } from 'jss';
3import { observer } from 'mobx-react'; 3import { observer } from 'mobx-react';
4import DevTools from 'mobx-react-devtools'; 4import DevTools from 'mobx-react-devtools';
5import React, { Component } from 'react'; 5import React from 'react';
6import injectSheet from 'react-jss'; 6import injectSheet from 'react-jss';
7 7
8import { WithTheme } from './withTheme'; 8import { WithTheme } from './withTheme';
diff --git a/uidev/src/stories/button.stories.tsx b/uidev/src/stories/button.stories.tsx
index c8e9bcbf3..f7537895c 100644
--- a/uidev/src/stories/button.stories.tsx
+++ b/uidev/src/stories/button.stories.tsx
@@ -1,8 +1,11 @@
1import { observable } from 'mobx'; 1import { observable } from 'mobx';
2import { observer } from 'mobx-react'; 2import { observer } from 'mobx-react';
3import React from 'react'; 3import React from 'react';
4import injectSheet from 'react-jss';
4 5
5import { Button } from '@meetfranz/forms'; 6import { Button, Input } from '@meetfranz/forms';
7import { classes } from 'istanbul-lib-coverage';
8import { Classes } from 'jss';
6import { storiesOf } from '../stores/stories'; 9import { storiesOf } from '../stores/stories';
7 10
8const defaultProps = { 11const defaultProps = {
@@ -13,6 +16,17 @@ const defaultProps = {
13 disabled: false, 16 disabled: false,
14}; 17};
15 18
19const styles = {
20 combinedElements: {
21 display: 'flex',
22 justifyContent: 'space-between',
23 },
24 input: {
25 flex: 1,
26 marginRight: 20,
27 },
28};
29
16const createStore = (args?: any) => { 30const createStore = (args?: any) => {
17 return observable(Object.assign({}, defaultProps, args)); 31 return observable(Object.assign({}, defaultProps, args));
18}; 32};
@@ -99,4 +113,26 @@ storiesOf('Button')
99 e.preventDefault(); 113 e.preventDefault();
100 alert('Click event'); 114 alert('Click event');
101 }, 115 },
102 })} />)); 116 })}/>
117 ))
118 .add('Long multi-line button', () => (
119 <WithStoreButton store={createStore({
120 label: 'But there is something that I must say to my people, who stand on the warm threshold which leads into the palace of justice: In the process of gaining our rightful place, we must not be guilty of wrongful deeds. Let us not seek to satisfy our thirst for freedom by drinking from the cup of bitterness and hatred. We must forever conduct our struggle on the high plane of dignity and discipline. We must not allow our creative protest to degenerate into physical violence. Again and again, we must rise to the majestic heights of meeting physical force with soul force.',
121 })} />
122 ))
123 .add('Button with Input', injectSheet(styles)(observer(({ classes }: { classes: Classes }) => (
124 <div className={classes.combinedElements}>
125 <Input showLabel={false} className={classes.input} noMargin />
126 <WithStoreButton store={createStore({})} />
127 </div>
128 )),
129 ))
130 .add('Icon Button with Input', injectSheet(styles)(observer(({ classes }: { classes: Classes }) => (
131 <div className={classes.combinedElements}>
132 <Input showLabel={false} className={classes.input} noMargin />
133 <WithStoreButton store={createStore({
134 icon: 'mdiInformation',
135 })} />
136 </div>
137 )),
138 ));