diff --git a/src/components/GenderRate/GenderRate.stories.tsx b/src/components/GenderRate/GenderRate.stories.tsx new file mode 100644 index 0000000..2214478 --- /dev/null +++ b/src/components/GenderRate/GenderRate.stories.tsx @@ -0,0 +1,17 @@ +import GenderRate, { GenderRateProps } from './GenderRate'; +import { ComponentMeta, ComponentStory } from '@storybook/react'; + +export default { + title: 'Component/GenderRate', + component: GenderRate, +} as ComponentMeta; + +const Template: ComponentStory = (args: GenderRateProps) => ( + +); + +export const Primary = Template.bind({}); + +Primary.args = { + genderRatio: 0, +}; diff --git a/src/components/GenderRate/GenderRate.tsx b/src/components/GenderRate/GenderRate.tsx new file mode 100644 index 0000000..971c627 --- /dev/null +++ b/src/components/GenderRate/GenderRate.tsx @@ -0,0 +1,120 @@ +export interface GenderRateProps { + genderRatio: number; +} + +const GenderRate = ({ genderRatio }: GenderRateProps) => { + switch (genderRatio) { + case 0: + return ( +
+ + 100% + + + {' '} + 0% + +
+ ); + case 1: + return ( +
+ + 87.5% + + + {' '} + 12.5% + +
+ ); + case 2: + return ( +
+ + 75% + + + {' '} + 25% + +
+ ); + case 3: + return ( +
+ + 62.5% + + + {' '} + 37.5% + +
+ ); + case 4: + return ( +
+ + 50% + + + {' '} + 50% + +
+ ); + case 5: + return ( +
+ + 37.5% + + + {' '} + 62.5% + +
+ ); + case 6: + return ( +
+ + 25% + + + {' '} + 75% + +
+ ); + case 7: + return ( +
+ + 12.5% + + + {' '} + 87.5% + +
+ ); + case 8: + return ( +
+ + 0% + + + {' '} + 100% + +
+ ); + default: + return Loading...; + } +}; + +export default GenderRate; diff --git a/src/components/GenderRate/index.ts b/src/components/GenderRate/index.ts new file mode 100644 index 0000000..2ec77ce --- /dev/null +++ b/src/components/GenderRate/index.ts @@ -0,0 +1 @@ +export { default } from './GenderRate';