|
| 1 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 2 | + |
| 3 | +import { Bleed } from "./Bleed"; |
| 4 | + |
| 5 | +const meta: Meta<typeof Bleed> = { |
| 6 | + title: "Components/Bleed", |
| 7 | + component: Bleed, |
| 8 | + tags: ["autodocs"], |
| 9 | + parameters: { |
| 10 | + docs: { |
| 11 | + description: { |
| 12 | + component: |
| 13 | + "Bleed 컴포넌트는 부모 요소의 여백(padding)을 무시하고 특정 방향으로 확장되어야 하는 UI를 구현할 때 사용됩니다. 이를 통해 페이지나 섹션의 전체 너비를 차지하는 컴포넌트를 쉽게 만들 수 있습니다.", |
| 14 | + }, |
| 15 | + }, |
| 16 | + }, |
| 17 | + argTypes: { |
| 18 | + as: { |
| 19 | + control: false, |
| 20 | + description: "컴포넌트의 HTML 태그를 설정합니다.", |
| 21 | + table: { |
| 22 | + type: { summary: "React.ElementType" }, |
| 23 | + defaultValue: { summary: "div" }, |
| 24 | + }, |
| 25 | + }, |
| 26 | + inline: { |
| 27 | + control: "number", |
| 28 | + description: |
| 29 | + "좌우 여백을 설정합니다. `inlineStart`와 `inlineEnd`를 동시에 설정합니다.", |
| 30 | + table: { |
| 31 | + type: { summary: "number | string" }, |
| 32 | + }, |
| 33 | + }, |
| 34 | + block: { |
| 35 | + control: "number", |
| 36 | + description: |
| 37 | + "상하 여백을 설정합니다. `blockStart`와 `blockEnd`를 동시에 설정합니다.", |
| 38 | + table: { |
| 39 | + type: { summary: "number | string" }, |
| 40 | + }, |
| 41 | + }, |
| 42 | + inlineStart: { |
| 43 | + control: "number", |
| 44 | + description: "시작 방향(LTR 환경에서는 왼쪽)의 여백을 설정합니다.", |
| 45 | + table: { |
| 46 | + type: { summary: "number | string" }, |
| 47 | + }, |
| 48 | + }, |
| 49 | + inlineEnd: { |
| 50 | + control: "number", |
| 51 | + description: "끝 방향(LTR 환경에서는 오른쪽)의 여백을 설정합니다.", |
| 52 | + table: { |
| 53 | + type: { summary: "number | string" }, |
| 54 | + }, |
| 55 | + }, |
| 56 | + blockStart: { |
| 57 | + control: "number", |
| 58 | + description: "위쪽 여백을 설정합니다.", |
| 59 | + table: { |
| 60 | + type: { summary: "number | string" }, |
| 61 | + }, |
| 62 | + }, |
| 63 | + blockEnd: { |
| 64 | + control: "number", |
| 65 | + description: "아래쪽 여백을 설정합니다.", |
| 66 | + table: { |
| 67 | + type: { summary: "number | string" }, |
| 68 | + }, |
| 69 | + }, |
| 70 | + }, |
| 71 | +}; |
| 72 | + |
| 73 | +export default meta; |
| 74 | +type Story = StoryObj<typeof Bleed>; |
| 75 | + |
| 76 | +export const InlineBleed: Story = { |
| 77 | + render: () => ( |
| 78 | + <div |
| 79 | + style={{ |
| 80 | + padding: "16px", |
| 81 | + backgroundColor: "rgba(255, 0, 0, 0.1)", |
| 82 | + width: "300px", |
| 83 | + }} |
| 84 | + > |
| 85 | + <div |
| 86 | + style={{ |
| 87 | + backgroundColor: "rgba(0, 255, 0, 0.1)", |
| 88 | + padding: "12px", |
| 89 | + textAlign: "center", |
| 90 | + }} |
| 91 | + > |
| 92 | + 컨텐츠 영역 |
| 93 | + </div> |
| 94 | + <Bleed inline={16}> |
| 95 | + <div |
| 96 | + style={{ |
| 97 | + backgroundColor: "rgba(0, 0, 255, 0.1)", |
| 98 | + padding: "12px", |
| 99 | + textAlign: "center", |
| 100 | + }} |
| 101 | + > |
| 102 | + Bleed 영역 |
| 103 | + </div> |
| 104 | + </Bleed> |
| 105 | + <div |
| 106 | + style={{ |
| 107 | + backgroundColor: "rgba(0, 255, 0, 0.1)", |
| 108 | + padding: "12px", |
| 109 | + textAlign: "center", |
| 110 | + marginTop: "8px", |
| 111 | + }} |
| 112 | + > |
| 113 | + 컨텐츠 영역 |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + ), |
| 117 | + parameters: { |
| 118 | + docs: { |
| 119 | + description: { |
| 120 | + story: |
| 121 | + "`inline` prop을 사용하여 좌우로 확장된 컴포넌트입니다. 부모 요소의 `padding`을 무시하고 좌우로 확장됩니다. 붉은 영역이 부모의 padding 영역을 시각화합니다.", |
| 122 | + }, |
| 123 | + }, |
| 124 | + }, |
| 125 | +}; |
| 126 | + |
| 127 | +export const BlockBleed: Story = { |
| 128 | + render: () => ( |
| 129 | + <div |
| 130 | + style={{ |
| 131 | + padding: "16px", |
| 132 | + backgroundColor: "rgba(255, 0, 0, 0.1)", |
| 133 | + }} |
| 134 | + > |
| 135 | + <div |
| 136 | + style={{ |
| 137 | + backgroundColor: "rgba(0, 255, 0, 0.1)", |
| 138 | + padding: "12px", |
| 139 | + textAlign: "center", |
| 140 | + }} |
| 141 | + > |
| 142 | + 컨텐츠 영역 |
| 143 | + </div> |
| 144 | + <Bleed block={16}> |
| 145 | + <div |
| 146 | + style={{ |
| 147 | + backgroundColor: "rgba(0, 0, 255, 0.1)", |
| 148 | + padding: "12px", |
| 149 | + textAlign: "center", |
| 150 | + }} |
| 151 | + > |
| 152 | + Bleed 영역 |
| 153 | + </div> |
| 154 | + </Bleed> |
| 155 | + <div |
| 156 | + style={{ |
| 157 | + backgroundColor: "rgba(0, 255, 0, 0.1)", |
| 158 | + padding: "12px", |
| 159 | + textAlign: "center", |
| 160 | + marginTop: "8px", |
| 161 | + }} |
| 162 | + > |
| 163 | + 컨텐츠 영역 |
| 164 | + </div> |
| 165 | + </div> |
| 166 | + ), |
| 167 | + parameters: { |
| 168 | + docs: { |
| 169 | + description: { |
| 170 | + story: |
| 171 | + "`block` prop을 사용하여 상하로 확장된 컴포넌트입니다. 부모 요소의 `padding`을 무시하고 상하로 확장됩니다. 붉은 영역이 부모의 padding 영역을 시각화합니다.", |
| 172 | + }, |
| 173 | + }, |
| 174 | + }, |
| 175 | +}; |
| 176 | + |
| 177 | +export const AllDirectionsBleed: Story = { |
| 178 | + render: () => ( |
| 179 | + <div |
| 180 | + style={{ |
| 181 | + padding: "16px", |
| 182 | + backgroundColor: "rgba(255, 0, 0, 0.1)", |
| 183 | + }} |
| 184 | + > |
| 185 | + <Bleed inline={16} block={16}> |
| 186 | + <div |
| 187 | + style={{ |
| 188 | + backgroundColor: "rgba(0, 0, 255, 0.1)", |
| 189 | + padding: "12px", |
| 190 | + textAlign: "center", |
| 191 | + }} |
| 192 | + > |
| 193 | + Bleed 영역 |
| 194 | + </div> |
| 195 | + </Bleed> |
| 196 | + </div> |
| 197 | + ), |
| 198 | + parameters: { |
| 199 | + docs: { |
| 200 | + description: { |
| 201 | + story: |
| 202 | + "`inline`과 `block` prop을 모두 사용하여 모든 방향으로 확장된 컴포넌트입니다.", |
| 203 | + }, |
| 204 | + }, |
| 205 | + }, |
| 206 | +}; |
0 commit comments