-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Progress): add initial progress
- Loading branch information
Showing
7 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
ProgressOuterTag, | ||
ProgressInnerTag, | ||
ProgressValueTag, | ||
ProgressTextTag, | ||
} from './Progress.theme'; | ||
|
||
type ProgressProps = {| | ||
value: number, | ||
|}; | ||
|
||
const Progress = ({ value, ...rest }: ProgressProps) => { | ||
value = value > 100 ? value % 100 : value; | ||
|
||
return ( | ||
<ProgressOuterTag { ...rest }> | ||
<ProgressInnerTag> | ||
<ProgressValueTag style={{ width: `${value}%` }} /> | ||
</ProgressInnerTag> | ||
<ProgressTextTag>{ value } %</ProgressTextTag> | ||
</ProgressOuterTag> | ||
); | ||
}; | ||
|
||
export { Progress }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
|
||
export default (asStory) => { | ||
asStory('ATOMS/Progress', module, (story, { Progress }) => { | ||
story | ||
.add('with default modifiers', () => ( | ||
<React.Fragment> | ||
<Progress value={ 0 } /> | ||
<br /> | ||
<Progress value={ 30 } /> | ||
<br /> | ||
<Progress value={ 50 } /> | ||
<br /> | ||
<Progress value={ 100 } /> | ||
<br /> | ||
</React.Fragment> | ||
)); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createStyledTag, createTheme } from '../../utils'; | ||
|
||
const name = 'progress'; | ||
|
||
export const theme = createTheme(name, { | ||
modifiers: { | ||
}, | ||
defaults: { | ||
}, | ||
}); | ||
|
||
export const ProgressOuterTag = createStyledTag(name, { | ||
width: '100%', | ||
display: 'flex', | ||
}); | ||
|
||
export const ProgressInnerTag = createStyledTag(`${name}Inner`, ({ theme }) => ({ | ||
heigth: '1.2rem', | ||
flex: '1', | ||
background: theme.COLORS.LIGHT_GRAY4, | ||
borderRadius: '1.2rem', | ||
})); | ||
|
||
export const ProgressValueTag = createStyledTag(`${name}Value`, ({ theme }) => ({ | ||
backgroundColor: theme.COLORS.PRIMARY, | ||
borderRadius: '1.2rem', | ||
height: '100%', | ||
})); | ||
|
||
export const ProgressTextTag = createStyledTag(`${name}Text`, ({ theme }) => ({ | ||
fontSize: '13px', | ||
fontWeight: '600', | ||
marginLeft: '1.2rem', | ||
whiteSpace: 'nowrap', | ||
color: theme.COLORS.PRIMARY, | ||
width: '3.6rem', | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { Progress } from './Progress'; | ||
export { theme } from './Progress.theme'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters