|
| 1 | +import {Col, Container, Flex, GridThemeProvider, Row} from '@acrool/react-grid'; |
| 2 | +import type {Meta, StoryObj} from '@storybook/react'; |
| 3 | +import React from 'react'; |
| 4 | + |
| 5 | +const meta = { |
| 6 | + title: 'Utilities/Mask', |
| 7 | + parameters: {}, |
| 8 | + argTypes: {}, |
| 9 | + args: {}, |
| 10 | + decorators: (Story) => ( |
| 11 | + <GridThemeProvider> |
| 12 | + <Story /> |
| 13 | + </GridThemeProvider> |
| 14 | + ), |
| 15 | +} satisfies Meta<typeof Flex>; |
| 16 | + |
| 17 | +export default meta; |
| 18 | +type Story = StoryObj<typeof meta>; |
| 19 | + |
| 20 | +// 測試用的圖片 URL |
| 21 | +const testImageUrl = 'https://picsum.photos/400/300'; |
| 22 | + |
| 23 | +// 各種 filter-mask 方向 |
| 24 | +const maskDirections = ['t', 'r', 'b', 'l', 'x', 'y']; |
| 25 | + |
| 26 | +export const FilterMaskDirections: Story = { |
| 27 | + args: {}, |
| 28 | + render: function Render(args: any) { |
| 29 | + return ( |
| 30 | + <Container {...args}> |
| 31 | + <Flex column className="gap-4"> |
| 32 | + <h2 className="text-center">Filter Mask 方向測試</h2> |
| 33 | + |
| 34 | + {maskDirections.map(direction => { |
| 35 | + const className = `filter-mask-${direction}`; |
| 36 | + |
| 37 | + return ( |
| 38 | + <div key={direction} className="mb-4"> |
| 39 | + <h3 className="mb-2">filter-mask-{direction}</h3> |
| 40 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 41 | + <img |
| 42 | + src={testImageUrl} |
| 43 | + alt={`Test image with ${className}`} |
| 44 | + className={`w-100 ${className}`} |
| 45 | + style={{height: '200px', objectFit: 'cover'}} |
| 46 | + /> |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + ); |
| 50 | + })} |
| 51 | + </Flex> |
| 52 | + </Container> |
| 53 | + ); |
| 54 | + }, |
| 55 | +}; |
| 56 | + |
| 57 | +export const FilterMaskWithContent: Story = { |
| 58 | + args: {}, |
| 59 | + render: function Render(args: any) { |
| 60 | + return ( |
| 61 | + <Container {...args}> |
| 62 | + <Flex column className="gap-4"> |
| 63 | + <h2 className="text-center">Filter Mask 內容測試</h2> |
| 64 | + |
| 65 | + <Row className="gap-4"> |
| 66 | + {maskDirections.map(direction => { |
| 67 | + const className = `filter-mask-${direction}`; |
| 68 | + |
| 69 | + return ( |
| 70 | + <Col key={direction} col={6} md={4}> |
| 71 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 72 | + <img |
| 73 | + src={testImageUrl} |
| 74 | + alt={`Test image with ${className}`} |
| 75 | + className={`w-100 ${className}`} |
| 76 | + style={{height: '150px', objectFit: 'cover'}} |
| 77 | + /> |
| 78 | + <div className="absolute-center text-center text-white"> |
| 79 | + <h4>Mask {direction.toUpperCase()}</h4> |
| 80 | + <p className="text-sm">filter-mask-{direction}</p> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + </Col> |
| 84 | + ); |
| 85 | + })} |
| 86 | + </Row> |
| 87 | + </Flex> |
| 88 | + </Container> |
| 89 | + ); |
| 90 | + }, |
| 91 | +}; |
| 92 | + |
| 93 | +export const FilterMaskBottom80: Story = { |
| 94 | + args: {}, |
| 95 | + render: function Render(args: any) { |
| 96 | + return ( |
| 97 | + <Container {...args}> |
| 98 | + <Flex column className="gap-4"> |
| 99 | + <h2 className="text-center">Filter Mask Bottom 80% 測試</h2> |
| 100 | + |
| 101 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 102 | + <img |
| 103 | + src={testImageUrl} |
| 104 | + alt="Test image with filter-mask-b-80" |
| 105 | + className="w-100 filter-mask-b-80" |
| 106 | + style={{height: '300px', objectFit: 'cover'}} |
| 107 | + /> |
| 108 | + <div className="absolute-center text-center text-white"> |
| 109 | + <h3>filter-mask-b-80</h3> |
| 110 | + <p>底部 80% 遮罩效果</p> |
| 111 | + </div> |
| 112 | + </div> |
| 113 | + </Flex> |
| 114 | + </Container> |
| 115 | + ); |
| 116 | + }, |
| 117 | +}; |
| 118 | + |
| 119 | +export const FilterMaskComparison: Story = { |
| 120 | + args: {}, |
| 121 | + render: function Render(args: any) { |
| 122 | + return ( |
| 123 | + <Container {...args}> |
| 124 | + <Flex column className="gap-4"> |
| 125 | + <h2 className="text-center">Filter Mask 對比測試</h2> |
| 126 | + |
| 127 | + <Row className="gap-4"> |
| 128 | + <Col col={6}> |
| 129 | + <h3 className="text-center mb-2">原始圖片</h3> |
| 130 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 131 | + <img |
| 132 | + src={testImageUrl} |
| 133 | + alt="Original test image" |
| 134 | + className="w-100" |
| 135 | + style={{height: '250px', objectFit: 'cover'}} |
| 136 | + /> |
| 137 | + </div> |
| 138 | + </Col> |
| 139 | + |
| 140 | + <Col col={6}> |
| 141 | + <h3 className="text-center mb-2">遮罩效果</h3> |
| 142 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 143 | + <img |
| 144 | + src={testImageUrl} |
| 145 | + alt="Test image with filter-mask-t" |
| 146 | + className="w-100 filter-mask-t" |
| 147 | + style={{height: '250px', objectFit: 'cover'}} |
| 148 | + /> |
| 149 | + <div className="absolute-center text-center text-white"> |
| 150 | + <h4>filter-mask-t</h4> |
| 151 | + <p className="text-sm">頂部遮罩</p> |
| 152 | + </div> |
| 153 | + </div> |
| 154 | + </Col> |
| 155 | + </Row> |
| 156 | + |
| 157 | + <Row className="gap-4 mt-4"> |
| 158 | + <Col col={4}> |
| 159 | + <h4 className="text-center mb-2">左側遮罩</h4> |
| 160 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 161 | + <img |
| 162 | + src={testImageUrl} |
| 163 | + alt="Test image with filter-mask-l" |
| 164 | + className="w-100 filter-mask-l" |
| 165 | + style={{height: '200px', objectFit: 'cover'}} |
| 166 | + /> |
| 167 | + </div> |
| 168 | + </Col> |
| 169 | + |
| 170 | + <Col col={4}> |
| 171 | + <h4 className="text-center mb-2">右側遮罩</h4> |
| 172 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 173 | + <img |
| 174 | + src={testImageUrl} |
| 175 | + alt="Test image with filter-mask-r" |
| 176 | + className="w-100 filter-mask-r" |
| 177 | + style={{height: '200px', objectFit: 'cover'}} |
| 178 | + /> |
| 179 | + </div> |
| 180 | + </Col> |
| 181 | + |
| 182 | + <Col col={4}> |
| 183 | + <h4 className="text-center mb-2">底部遮罩</h4> |
| 184 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 185 | + <img |
| 186 | + src={testImageUrl} |
| 187 | + alt="Test image with filter-mask-b" |
| 188 | + className="w-100 filter-mask-b" |
| 189 | + style={{height: '200px', objectFit: 'cover'}} |
| 190 | + /> |
| 191 | + </div> |
| 192 | + </Col> |
| 193 | + </Row> |
| 194 | + </Flex> |
| 195 | + </Container> |
| 196 | + ); |
| 197 | + }, |
| 198 | +}; |
| 199 | + |
| 200 | +export const FilterMaskInteractive: Story = { |
| 201 | + args: {}, |
| 202 | + render: function Render(args: any) { |
| 203 | + return ( |
| 204 | + <Container {...args}> |
| 205 | + <Flex column className="gap-4"> |
| 206 | + <h2 className="text-center">Filter Mask 互動測試</h2> |
| 207 | + |
| 208 | + <Row className="gap-4"> |
| 209 | + <Col col={12} md={6}> |
| 210 | + <h3 className="text-center mb-2">水平遮罩 (X軸)</h3> |
| 211 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 212 | + <img |
| 213 | + src={testImageUrl} |
| 214 | + alt="Test image with filter-mask-x" |
| 215 | + className="w-100 filter-mask-x" |
| 216 | + style={{height: '250px', objectFit: 'cover'}} |
| 217 | + /> |
| 218 | + <div className="absolute-center text-center text-white"> |
| 219 | + <h4>filter-mask-x</h4> |
| 220 | + <p className="text-sm">左右兩側遮罩</p> |
| 221 | + </div> |
| 222 | + </div> |
| 223 | + </Col> |
| 224 | + |
| 225 | + <Col col={12} md={6}> |
| 226 | + <h3 className="text-center mb-2">垂直遮罩 (Y軸)</h3> |
| 227 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 228 | + <img |
| 229 | + src={testImageUrl} |
| 230 | + alt="Test image with filter-mask-y" |
| 231 | + className="w-100 filter-mask-y" |
| 232 | + style={{height: '250px', objectFit: 'cover'}} |
| 233 | + /> |
| 234 | + <div className="absolute-center text-center text-white"> |
| 235 | + <h4>filter-mask-y</h4> |
| 236 | + <p className="text-sm">上下兩側遮罩</p> |
| 237 | + </div> |
| 238 | + </div> |
| 239 | + </Col> |
| 240 | + </Row> |
| 241 | + |
| 242 | + <Row className="gap-4 mt-4"> |
| 243 | + <Col col={12}> |
| 244 | + <h3 className="text-center mb-2">特殊遮罩效果</h3> |
| 245 | + <div className="relative overflow-hidden rounded" style={{backgroundColor: '#f8f9fa'}}> |
| 246 | + <img |
| 247 | + src={testImageUrl} |
| 248 | + alt="Test image with filter-mask-b-80" |
| 249 | + className="w-100 filter-mask-b-80" |
| 250 | + style={{height: '300px', objectFit: 'cover'}} |
| 251 | + /> |
| 252 | + <div className="absolute-center text-center text-white"> |
| 253 | + <h4>filter-mask-b-80</h4> |
| 254 | + <p className="text-sm">底部 80% 漸變遮罩</p> |
| 255 | + <p className="text-sm">從底部開始漸變到透明</p> |
| 256 | + </div> |
| 257 | + </div> |
| 258 | + </Col> |
| 259 | + </Row> |
| 260 | + </Flex> |
| 261 | + </Container> |
| 262 | + ); |
| 263 | + }, |
| 264 | +}; |
| 265 | + |
0 commit comments