Skip to content
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

feat: Implement Accordion component with storybook #16 #17

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/workshop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
},
"devDependencies": {
"@jung/configs": "workspace:*",
"@vitejs/plugin-react-swc": "latest",
"@vitest/coverage-v8": "^1.3.1",
"@vitest/ui": "^1.3.1",
"vitest": "^1.3.1",
"@svgr/rollup": "^8.1.0",
"@vanilla-extract/vite-plugin": "latest",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-interactions": "^7.6.17",
"@storybook/addon-links": "^7.6.17",
Expand Down
83 changes: 83 additions & 0 deletions apps/workshop/src/stories/Accordion/Accordion.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Accordion } from '@jung/design-system';
import type { Meta, StoryObj } from '@storybook/react';

const meta: Meta<typeof Accordion> = {
title: 'Components/Accordion',
component: Accordion,
tags: ['autodocs'],
parameters: {
layout: 'centered',
},
} satisfies Meta<typeof Accordion>;

export default meta;
type Story = StoryObj<typeof Accordion>;

export const Default: Story = {
render: (args) => (
<Accordion style={{ width: '375px' }} {...args}>
<Accordion.Item>
<Accordion.Trigger top={<div>Answered 2024.02.23 | Delete</div>}>
What is the Virtual DOM and how does it work in React?
</Accordion.Trigger>
<Accordion.Content>
<Accordion.Panel title="Answer">
The Virtual DOM is a lightweight copy of the actual DOM used by
React to optimize the update process. By rendering a virtual
representation of the UI, React can minimize direct DOM
manipulations and improve performance.
</Accordion.Panel>
<Accordion.Panel title="Follow-up Question 1">
How does React determine what to re-render in the DOM when state
changes?
</Accordion.Panel>
<Accordion.Panel title="Answer">
React uses a diffing algorithm, which compares the previous and the
new versions of the Virtual DOM to determine the minimal set of
changes necessary to update the actual DOM.
</Accordion.Panel>
<Accordion.Panel title="Follow-up Question 2">
What are the benefits of using the Virtual DOM compared to direct
DOM manipulation?
</Accordion.Panel>
<Accordion.Panel title="Answer">
Using the Virtual DOM reduces the cost of DOM updates, which can be
performance-intensive. It allows for efficient updates by batching
them and only touching the parts of the DOM that actually need to
change.
</Accordion.Panel>
</Accordion.Content>
</Accordion.Item>
<Accordion.Item>
<Accordion.Trigger top={<div>Answered 2023.07.19 | Delete</div>}>
Can you explain the difference between `var`, `let`, and `const` in
JavaScript?
</Accordion.Trigger>
<Accordion.Content>
<Accordion.Panel>
`var` is function-scoped, while `let` and `const` are block-scoped.
This scoping difference is crucial for managing variable visibility
and lifecycle in JavaScript applications.
</Accordion.Panel>
<Accordion.Panel title="Follow-up Question 1">
What issues might arise from using `var` in modern JavaScript?
</Accordion.Panel>
<Accordion.Panel title="Answer">
Using `var` can lead to common issues like variable hoisting and
unintended variable overriding, especially in loops or conditional
blocks, which can introduce bugs and make code maintenance harder.
</Accordion.Panel>
<Accordion.Panel title="Follow-up Question 2">
Why might you choose `const` over `let` when declaring a variable?
</Accordion.Panel>
<Accordion.Panel title="Answer">
Choosing `const` helps enforce immutability for the variable's
value, which can lead to safer, more predictable code. It's a best
practice when the variable's value should not change after initial
assignment.
</Accordion.Panel>
</Accordion.Content>
</Accordion.Item>
</Accordion>
),
};
3 changes: 2 additions & 1 deletion apps/workshop/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import svgr from '@svgr/rollup';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), vanillaExtractPlugin()],
plugins: [react(),svgr(), vanillaExtractPlugin()],
test: {
globals: true,
environment: 'jsdom',
Expand Down
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.
3 changes: 3 additions & 0 deletions packages/design-system/assets/icons/ic-arrow-up-outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/design-system/assets/icons/ic-close-outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/design-system/assets/icons/ic-delete-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/design-system/assets/icons/ic-happy-outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/design-system/assets/icons/ic-happy-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/design-system/assets/icons/ic-heart-solid-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/design-system/assets/icons/ic-heart-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/design-system/assets/icons/ic-plus-outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/design-system/assets/icons/ic-pollygon-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/design-system/assets/icons/ic-pollygon-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/design-system/assets/icons/ic-sad-outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/design-system/assets/icons/ic-sad-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/design-system/assets/icons/ic-smile-outlined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/design-system/assets/icons/ic-smile-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/design-system/assets/icons/ic-social-apple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading