Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/pages/components/Input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Input

Primitive Input component with variants

```.jsx
<Input />
```
10 changes: 9 additions & 1 deletion docs/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
background: 'white',
borderGray: '#ddd',
lightGray: '#00000080',
darkGray: '#888',
},

buttons: {
Expand Down Expand Up @@ -64,7 +65,7 @@ export default {
},
placeholderVariants: {
primary: {
color: 'red',
color: 'darkGray',
},
},
breakpoints: [
Expand Down Expand Up @@ -106,4 +107,11 @@ export default {
color: 'white',
},
},
forms: {
input: {
p: 3,
borderColor: 'border',
borderRadius: 2,
}
}
};
6 changes: 5 additions & 1 deletion src/components/input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Input } from 'theme-ui';
import styled from '@emotion/styled';
import withPlaceholderVariant from '../utils/placeholderVariant';
import { applyFocus } from '../utils/getStyles';

export default withPlaceholderVariant(Input);
export default styled(withPlaceholderVariant(Input))`
${({theme}) => applyFocus(theme)}
`;
14 changes: 13 additions & 1 deletion src/components/modal/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,34 @@ export const Overlay = styled(Fixed)(
left: 0,
width: '100%',
height: '100%',
background: 'rgba(0, 0, 0, 0.5)',
background: 'rgba(0, 0, 0, 0.7)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
'&.modal-enter': {
opacity: 0,
'> div': {
transform: 'scale(0.95)',
transition: 'all 200ms linear',
},
},
'&.modal-enter-active': {
opacity: 1,
transition: 'all 200ms ease-in',
'> div': {
transform: 'scale(1)',
},
},
'&.modal-exit': {
opacity: 1,
},
'&.modal-exit-active': {
opacity: 0,
transition: 'all 200ms ease-out',
'> div': {
transform: 'scale(0.95)',
transition: 'all 200ms linear',
},
},
},
getStyleForVariant('overlay'),
Expand All @@ -42,6 +53,7 @@ export const ContentContainer = styled(Relative)(
width: '60%',
minHeight: '40%',
borderRadius: 1,
boxShadow: '0 1px 15px rgba(0,0,0,.75)',
})(theme),
getStyleForVariant('contentContainer'),
);
Expand Down
6 changes: 5 additions & 1 deletion src/components/select.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import styled from '@emotion/styled';
import { Select } from 'theme-ui';
import withPlaceholderVariant from '../utils/placeholderVariant';
import { applyFocus } from '../utils/getStyles';

export default withPlaceholderVariant(Select);
export default styled(withPlaceholderVariant(Select))`
${({theme}) => applyFocus(theme)}
`;
6 changes: 5 additions & 1 deletion src/components/textArea.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import styled from '@emotion/styled';
import { Textarea } from 'theme-ui';
import withPlaceholderVariant from '../utils/placeholderVariant';
import { applyFocus } from '../utils/getStyles';

export default withPlaceholderVariant(Textarea);
export default styled(withPlaceholderVariant(Textarea))`
${({theme}) => applyFocus(theme)}
`;
9 changes: 9 additions & 0 deletions src/utils/getVariations.js → src/utils/getStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { css, get } from 'theme-ui';
const applyVariation = (theme, variant, themeKey) =>
css(get(theme, themeKey + '.' + variant, get(theme, variant)));

const applyFocus = (theme) => css({
'&:focus': {
boxShadow: '#add9f5 0px 0px 0px 2px',
outline: 'none',
borderColor: 'info',
},
})(theme);

export {
applyVariation,
applyFocus,
};
2 changes: 1 addition & 1 deletion src/utils/placeholderVariant.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from '@emotion/styled';
import {
applyVariation,
} from './getVariations';
} from './getStyles';

export default (comp) => {
const variantStyles = ({
Expand Down