Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3356d35

Browse files
Percentage story fix
1 parent 9a96cb8 commit 3356d35

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

‎src/components/Percentage.jsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const StyledPercentage = styled.h1`
1717
width: 10rem;
1818
`;
1919

20-
const Percentage = ({ answers }) => {
20+
exportconst Percentage = ({ answers }) => {
2121
let level = 'red';
2222
let correct = 0;
2323

‎stories/Percentage.stories.js‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
import React from 'react';
22
import { storiesOf } from '@storybook/react';
3-
import Percentage from '../src/components/Percentage';
3+
import { Percentage } from '../src/components/Percentage';
4+
5+
const initialArray = (n, isAnswered, isCorrect) => {
6+
let arr = Array(...Array(n));
7+
8+
return arr.map((x, i) => {
9+
return {
10+
patternId: null,
11+
answerId: null,
12+
answered: isAnswered,
13+
correct: isCorrect,
14+
uuid: i
15+
};
16+
});
17+
};
18+
19+
const answers0 = initialArray(23, true, false);
20+
const answers50 = [...initialArray(11, true, false), ...initialArray(12, true, true)];
21+
const answers100 = initialArray(23, true, true);
422

523
storiesOf('Percentage', module)
6-
.add('under 40', () => <Percentage percent={30} />)
7-
.add('between 40 and 70', () => <Percentage percent={60} />)
8-
.add('over 70', () => <Percentage percent={90} />);
24+
.add('under 40', () => <Percentage answers={answers0} />)
25+
.add('between 40 and 70', () => <Percentage answers={answers50} />)
26+
.add('over 70', () => <Percentage answers={answers100} />);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /