-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from DaleStudy/150-new-badges
변경된 등급 이미지 적용
- Loading branch information
Showing
19 changed files
with
142 additions
and
47 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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,22 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import Card from "./GradeImage"; | ||
import { Grade } from "../../api/services/types"; | ||
|
||
const meta: Meta<typeof Card> = { | ||
component: Card, | ||
args: { | ||
grade: Grade.SEED, | ||
width: 105, | ||
height: 128, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Seed: StoryObj<typeof Card> = { | ||
args: { | ||
grade: Grade.SEED, | ||
width: 105, | ||
height: 128, | ||
}, | ||
}; |
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,35 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { expect, test } from "vitest"; | ||
|
||
import { Grade } from "../../api/services/types"; | ||
|
||
import GradeImage from "./GradeImage"; | ||
|
||
test.each(Object.values(Grade))( | ||
"attach alternative text for %s image", | ||
(grade) => { | ||
render( | ||
<GradeImage | ||
grade={grade} | ||
width={faker.number.int({ min: 1, max: 800 })} | ||
height={faker.number.int({ min: 1, max: 800 })} | ||
/>, | ||
); | ||
|
||
expect(screen.getByRole("img")).toHaveAccessibleName(`${grade} image`); | ||
}, | ||
); | ||
|
||
test("set width and height", () => { | ||
render( | ||
<GradeImage | ||
grade={faker.helpers.arrayElement(Object.values(Grade))} | ||
width={105} | ||
height={128} | ||
/>, | ||
); | ||
|
||
expect(screen.getByRole("img")).toHaveAttribute("width", "105"); | ||
expect(screen.getByRole("img")).toHaveAttribute("height", "128"); | ||
}); |
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,33 @@ | ||
import { Grade } from "../../api/services/types"; | ||
import SeedImage from "../../assets/GradeSeed.png"; | ||
import SproutImage from "../../assets/GradeSprout.png"; | ||
import LeafImage from "../../assets/GradeLeaf.png"; | ||
import BranchImage from "../../assets/GradeBranch.png"; | ||
import FruitImage from "../../assets/GradeFruit.png"; | ||
import TreeImage from "../../assets/GradeTree.png"; | ||
|
||
const imageTable = { | ||
SEED: SeedImage, | ||
SPROUT: SproutImage, | ||
LEAF: LeafImage, | ||
BRANCH: BranchImage, | ||
FRUIT: FruitImage, | ||
TREE: TreeImage, | ||
}; | ||
|
||
interface GradeImageProps { | ||
grade: Grade; | ||
height: number; | ||
width: number; | ||
} | ||
|
||
export default function GradeImage({ grade, height, width }: GradeImageProps) { | ||
return ( | ||
<img | ||
src={imageTable[grade]} | ||
alt={`${grade} image`} | ||
height={height} | ||
width={width} | ||
/> | ||
); | ||
} |
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