-
Notifications
You must be signed in to change notification settings - Fork 3
WIP: Dropzone #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
WIP: Dropzone #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,4 +27,6 @@ typings/ | |
| .env | ||
| .next | ||
| src/**/*.d.ts | ||
| test | ||
| test | ||
| .history | ||
| .prettierrc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "trailingComma": "es5", | ||
| "tabWidth": 4, | ||
| "singleQuote": true, | ||
| "bracketSpacing": true, | ||
| "arrowParens": "always" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import React from 'react'; | ||
| import { Text } from '../../Typography/Text'; | ||
| import { | ||
| StyledLoadingCircle, | ||
| StyledSVG, | ||
| StyledSVGCircleOne, | ||
| StyledSVGCircleTwo, | ||
| StyledLoadingCircleText, | ||
| } from './style/Circle.style'; | ||
| import { Type } from 'src/types'; | ||
|
|
||
| interface LoadingCircleProps { | ||
| progress: number; | ||
| } | ||
|
|
||
| export const LoadingCircle: React.FC<LoadingCircleProps> = (props) => { | ||
| const { progress } = props; | ||
| const totalDashOffset = 251; | ||
| const currentDashOffset = | ||
| totalDashOffset - progress * (totalDashOffset / 100); | ||
| let circleTwoType: Type = 'error'; | ||
|
|
||
| if (progress > 25) { | ||
| circleTwoType = 'warning'; | ||
| } | ||
| if (progress > 50) { | ||
| circleTwoType = 'primary'; | ||
| } | ||
| if (progress > 75) { | ||
| circleTwoType = 'success'; | ||
| } | ||
|
|
||
| return ( | ||
| <StyledLoadingCircle> | ||
| <StyledSVG height="100" width="100" className="svg"> | ||
| <StyledSVGCircleOne cx="50" cy="50" r="40" fill="none" /> | ||
| <StyledSVGCircleTwo | ||
| cx="50" | ||
| cy="50" | ||
| r="40" | ||
| fill="none" | ||
| type={circleTwoType} | ||
| dashOffset={currentDashOffset} | ||
| /> | ||
| </StyledSVG> | ||
| <StyledLoadingCircleText key={progress} type={circleTwoType}> | ||
| {`${progress}%`} | ||
| </StyledLoadingCircleText> | ||
| </StyledLoadingCircle> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './Circle'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import styled, { css } from 'styled-components'; | ||
| import { Text } from '../../../Typography/Text'; | ||
| import { Type } from 'src/types'; | ||
|
|
||
| interface StyledSVGCircleTwoProps { | ||
| type: Type; | ||
| dashOffset: number; | ||
| } | ||
|
|
||
| interface StyledSVGCircleText { | ||
| type: Type; | ||
| key: number; | ||
| } | ||
|
|
||
| export const StyledLoadingCircle = styled.div` | ||
| height: 100px; | ||
| width: 100px; | ||
| position: relative; | ||
| `; | ||
|
|
||
| export const StyledSVG = styled.svg` | ||
| display: block; | ||
| max-width: 100%; | ||
| `; | ||
|
|
||
| export const StyledSVGCircleOne = styled.circle` | ||
| stroke: ${(props) => props.theme.color.border}; | ||
| stroke-width: 3px; | ||
| `; | ||
|
|
||
| export const StyledSVGCircleTwo = styled.circle<StyledSVGCircleTwoProps>` | ||
| stroke-width: 3px; | ||
| stroke-dasharray: 251; | ||
| stroke-dashoffset: ${(props) => props.dashOffset}; | ||
| transform-origin: 50% 50%; | ||
| transform: rotate(-90deg); | ||
| transition: stroke 1s ease; | ||
|
|
||
| ${(props) => | ||
| props.type === 'error' && | ||
| css` | ||
| stroke: ${props.theme.color.error.alpha}; | ||
| `} | ||
|
|
||
| ${(props) => | ||
| props.type === 'warning' && | ||
| css` | ||
| stroke: ${props.theme.color.warning.alpha}; | ||
| `} | ||
|
|
||
| ${(props) => | ||
| props.type === 'primary' && | ||
| css` | ||
| stroke: ${props.theme.color.primary.alpha}; | ||
| `} | ||
|
|
||
| ${(props) => | ||
| props.type === 'success' && | ||
| css` | ||
| stroke: ${props.theme.color.success.alpha}; | ||
| `} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jednotlivé bloky bych odděloval řádkem. Blokem mám na mysli například toto |
||
| `; | ||
|
|
||
| export const StyledLoadingCircleText = styled(Text)<StyledSVGCircleText>` | ||
| font-size: 26px; | ||
| text-anchor: middle; | ||
| font-weight: bold; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jednotky pro |
||
| position: absolute; | ||
| top: 25px; | ||
| left: 50%; | ||
| transform: translateX(-50%); | ||
| transition: color 1s ease; | ||
|
|
||
| ${(props) => | ||
| props.type === 'error' && | ||
| css` | ||
| color: ${props.theme.color.error.alpha}; | ||
| `} | ||
|
|
||
| ${(props) => | ||
| props.type === 'warning' && | ||
| css` | ||
| color: ${props.theme.color.warning.alpha}; | ||
| `} | ||
|
|
||
| ${(props) => | ||
| props.type === 'primary' && | ||
| css` | ||
| color: ${props.theme.color.primary.alpha}; | ||
| `} | ||
|
|
||
| ${(props) => | ||
| props.type === 'success' && | ||
| css` | ||
| color: ${props.theme.color.success.alpha}; | ||
| `} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Zde bych taky jednotlivé bloky oddělil řádkem :) |
||
|
|
||
| `; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './Circle.style'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { select, text, withKnobs, number } from '@storybook/addon-knobs'; | ||
| import { storiesOf } from '@storybook/react'; | ||
| import * as React from 'react'; | ||
| import { specs } from 'storybook-addon-specifications'; | ||
| import { defaultValues } from '../../constants/defaultValues'; | ||
| import { Component, tests } from './DropZone.test'; | ||
| import { DropZone } from './DropZone'; | ||
|
|
||
| const stories = storiesOf('DropZone', module); | ||
|
|
||
| stories.addDecorator(withKnobs); | ||
|
|
||
| stories.add( | ||
| 'Overview', | ||
| () => { | ||
| return ( | ||
| <> | ||
| <DropZone /> | ||
| </> | ||
| ); | ||
| }, | ||
| { | ||
| info: { inline: true }, | ||
| } | ||
| ); | ||
|
|
||
| stories.add( | ||
| 'Playground', | ||
| () => { | ||
| const size = select( | ||
| `size:`, | ||
| ['small', `medium`, 'large'], | ||
| defaultValues.size | ||
| ); | ||
| const type = select( | ||
| `type:`, | ||
| ['primary', 'success', 'warning', 'error'], | ||
| defaultValues.type | ||
| ); | ||
| const state = select(`state:`, ['default', 'uploading'], 'default'); | ||
| const progress = number(`progress: `, 0); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To tu už nepotřebujeme. Raději bych to smazal :) + všechno, co na tuto proměnnou navazuje. Kdyžtak na to mrknem spolu ;) |
||
|
|
||
| const dropZone = Component(size, type, state, progress); | ||
|
|
||
| specs(() => tests(dropZone)); | ||
|
|
||
| return dropZone; | ||
| }, | ||
| { | ||
| info: { inline: true }, | ||
| } | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { shallow } from 'enzyme'; | ||
| import React from 'react'; | ||
| import { defaultValues } from '../../constants/defaultValues'; | ||
| import expect from 'expect'; | ||
| import { DropZone } from './DropZone'; | ||
|
|
||
| export const Component = (size, type, state, progress) => { | ||
| return ( | ||
| <DropZone size={size} type={type} state={state} progress={progress} /> | ||
| ); | ||
| }; | ||
|
|
||
| export const tests = (dropZone = Component()) => { | ||
| let output = shallow(dropZone); | ||
| }; | ||
|
|
||
| tests(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smazal bych tento soubor. Už ho tu jednou máme jako
.prettierrc.json