feat(ott-36): added button and input components

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
mirlan.maksitaliev 6 years ago
parent 9ea4b9ef13
commit 56e99e6291
  1. 1
      .eslintrc
  2. 4
      package.json
  3. 1
      public/index.html
  4. 19
      src/features/Button/index.tsx
  5. 20
      src/features/Button/stories.tsx
  6. 1
      src/features/Components/Button/index.tsx
  7. 21
      src/features/Components/Button/stories.tsx
  8. 44
      src/features/Components/Button/styled.tsx
  9. 58
      src/features/Components/Input/index.tsx
  10. 35
      src/features/Components/Input/stories.tsx
  11. 70
      src/features/Components/Input/styled.tsx
  12. 2
      src/features/Components/index.tsx
  13. 46
      src/features/GlobalStyles/index.tsx

@ -84,6 +84,7 @@
"indent": "off", "indent": "off",
"no-unused-vars": "off", "no-unused-vars": "off",
"react/jsx-one-expression-per-line": "off", "react/jsx-one-expression-per-line": "off",
"react/jsx-fragments": "off",
"semi": "off" "semi": "off"
} }
} }

@ -16,7 +16,8 @@
"lodash": "^4.17.15", "lodash": "^4.17.15",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-scripts": "3.4.1" "react-scripts": "3.4.1",
"styled-components": "^5.1.1"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^8.3.5", "@commitlint/cli": "^8.3.5",
@ -36,6 +37,7 @@
"@types/node": "^12.0.0", "@types/node": "^12.0.0",
"@types/react": "^16.9.0", "@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0", "@types/react-dom": "^16.9.0",
"@types/styled-components": "^5.1.0",
"commitizen": "^4.1.2", "commitizen": "^4.1.2",
"eslint": "6.8.0", "eslint": "6.8.0",
"eslint-config-airbnb": "18.1.0", "eslint-config-airbnb": "18.1.0",

@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" /> <meta name="theme-color" content="#000000" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,700;1,400&display=swap" rel="stylesheet">
<title>Instat TV</title> <title>Instat TV</title>
</head> </head>
<body> <body>

@ -1,19 +0,0 @@
import React, { ReactNode } from 'react'
type ButtonProps = {
children: ReactNode,
/**
* Simple click handler
*/
onClick?: () => void,
}
/**
* The world's most _basic_ button
*/
export const Button = ({ children, onClick }: ButtonProps) => (
<button onClick={onClick} type='button'>
{children}
</button>
)

@ -1,20 +0,0 @@
import React from 'react'
import { action } from '@storybook/addon-actions'
import { Button } from 'features/Button'
export default {
component: Button,
title: 'Button',
}
export const Text = () => <Button onClick={action('clicked')}>Hello Button</Button>
export const Emoji = () => (
<Button onClick={action('clicked')}>
<span role='img' aria-label='so cool'>
😀 😎 👍 💯
</span>
</Button>
)

@ -0,0 +1 @@
export * from './styled'

@ -0,0 +1,21 @@
import React from 'react'
import { action } from '@storybook/addon-actions'
import { ButtonOutline, ButtonSolid } from 'features/Components'
export default {
title: 'Button',
}
export const Solid = () => (
<ButtonSolid onClick={action('clicked')}>
Solid
</ButtonSolid>
)
export const Outline = () => (
<ButtonOutline onClick={action('clicked')}>
Outline
</ButtonOutline>
)

@ -0,0 +1,44 @@
import styled, { css } from 'styled-components/macro'
const baseButtonStyles = css`
width: 272px;
height: 48px;
border-width: 0.7px;
border-style: solid;
border-radius: 2px;
padding: 0 12px;
font-style: normal;
font-size: 20px;
outline-color: white;
`
export const outlineButtonStyles = css`
${baseButtonStyles}
padding-top: 8.6px;
padding-bottom: 10.6px;
color: ${({ theme: { colors } }) => colors.secondary};
font-weight: normal;
border-color: ${({ theme: { colors } }) => colors.secondary};
background: transparent;
`
export const solidButtonStyles = css`
${baseButtonStyles}
padding-top: 18.5px;
padding-bottom: 13px;
color: #FFFFFF;
font-weight: bold;
border-color: transparent;
background: ${({ theme: { colors } }) => colors.primary};
`
export const ButtonSolid = styled.button`
${solidButtonStyles}
`
export const ButtonOutline = styled.button`
${outlineButtonStyles}
`

@ -0,0 +1,58 @@
import React from 'react'
import {
TInputWrapper,
InputWrapper,
InputStyled,
Label,
} from './styled'
type TInput = {
defaultValue?: string,
id: string,
inputWidth?: number,
label: string,
labelWidth?: number,
maxLength?: number,
onChange?: () => void,
required?: boolean,
type?: string,
value?: string,
} & TInputWrapper
export const Input = ({
defaultValue,
id,
inputWidth,
label,
labelWidth,
maxLength,
onChange,
px,
required,
type,
value,
wrapperWidth,
}: TInput) => (
<InputWrapper
wrapperWidth={wrapperWidth}
px={px}
>
<Label
htmlFor={id}
labelWidth={labelWidth}
>
{label}
</Label>
<InputStyled
id={id}
type={type}
required={required}
value={value}
defaultValue={defaultValue}
onChange={onChange}
maxLength={maxLength}
inputWidth={inputWidth}
/>
</InputWrapper>
)

@ -0,0 +1,35 @@
import React, { Fragment } from 'react'
import { Input } from 'features/Components'
export default {
component: Input,
title: 'Input',
}
export const Empty = () => (
<Input
id='email'
type='email'
label='Email'
/>
)
export const EmailPassword = () => (
<Fragment>
<Input
id='email'
type='email'
label='Email'
labelWidth={72}
defaultValue='someveeeeeeeeerylooooooooong@email.com'
/>
<Input
id='password'
type='password'
label='Password'
labelWidth={72}
defaultValue='abcdefgh'
/>
</Fragment>
)

@ -0,0 +1,70 @@
import styled from 'styled-components/macro'
export type TInputWrapper = {
px?: number,
wrapperWidth?: number,
}
export const InputWrapper = styled.div<TInputWrapper>`
width: ${({ wrapperWidth }) => (wrapperWidth ? `${wrapperWidth}px` : '100%')};
height: 48px;
margin: 20px 0;
padding-left: ${({ px = 24 }) => (px ? `${px}px` : '')};
padding-right: ${({ px = 24 }) => (px ? `${px}px` : '')};
padding-top: 13px;
padding-bottom: 11px;
display: flex;
align-items: center;
background-color: #3F3F3F;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);
border-radius: 2px;
`
type TLabel = {
labelWidth?: number,
}
export const Label = styled.label<TLabel>`
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 24px;
letter-spacing: -0.01em;
padding-top: 2px;
color: ${({ theme: { colors } }) => colors.secondary};
width: ${({ labelWidth }) => (labelWidth ? `${labelWidth}px` : '')};
`
type TInputStyled = {
inputWidth?: number,
}
export const InputStyled = styled.input<TInputStyled>`
flex-grow: 1;
font-weight: bold;
font-size: 20px;
line-height: 24px;
width: ${({ inputWidth }) => (inputWidth ? `${inputWidth}px` : '')};
background-color: transparent;
border: transparent;
margin-left: 24px;
color: ${({ theme: { colors } }) => colors.text};
&[type='password'] {
letter-spacing: 6px;
}
:focus {
border-color: transparent;
outline: none;
}
:-webkit-autofill,
:-webkit-autofill:hover,
:-webkit-autofill:focus,
:-webkit-autofill:active {
box-shadow: 0 0 0 30px #3F3F3F inset;
caret-color: ${({ theme: { colors } }) => colors.text};
-webkit-text-fill-color: ${({ theme: { colors } }) => colors.text};
}
`

@ -0,0 +1,2 @@
export * from './Input'
export * from './Button'

@ -0,0 +1,46 @@
import { createGlobalStyle } from 'styled-components/macro'
export const GlobalStyles = createGlobalStyle`
*, *:before, *:after {
box-sizing: border-box;
}
body {
min-height: 100vh;
margin: 0;
padding: 0;
font-family: Montserrat, Tahoma, sans-serif;
font-size: 12px;
line-height: 12px;
color: #000;
}
h1, h2, h3, h4, h5, h6, p, ul, li {
margin: 0;
padding: 0;
font-size: 12px;
line-height: 12px;
}
ul, li {
list-style: none;
}
a {
text-decoration: none;
color: #000;
}
fieldset {
margin: 0;
min-width: 0;
padding: 0;
border: 0;
}
button, input, select, textarea {
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
`
Loading…
Cancel
Save