Repository navigation
[component] feature: MaskedEdge #488
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
base: main
Are you sure you want to change the base?
Changes from all commits
a686ba9
d6a35fe
c114126
133505a
fafeb45
b35e505
ca806f0
dc5d2aa
aa045ac
cf7dc29
a73ce47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| export * from "./breakpoint-snipe" | ||
|
Check failure on line 1 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./flex" | ||
|
Check failure on line 2 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./grid-layout" | ||
|
Check failure on line 3 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./icon" | ||
|
Check failure on line 4 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./image-group" | ||
|
Check failure on line 5 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./in-view" | ||
|
Check failure on line 6 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./modal" | ||
|
Check failure on line 7 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./navigation" | ||
| export * from "./masked-edge" | ||
|
Check failure on line 9 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./tag" | ||
|
Check failure on line 10 in packages/wethegit-components/src/components/index.tsx
|
||
| export * from "./text" | ||
| export * from "./visually-hidden" | ||
| export * from "./visually-hidden-links" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| .maskedEdge { | ||
| position: relative; | ||
| } | ||
|
|
||
| .maskSizer { | ||
| /* For container units */ | ||
| container-type: size; | ||
| inset: 0; | ||
| pointer-events: none; | ||
| position: absolute; | ||
| } | ||
|
|
||
| /* Holds the inline SVG mask without taking up space */ | ||
| .maskDefs { | ||
| height: 0; | ||
| overflow: hidden; | ||
| pointer-events: none; | ||
| position: absolute; | ||
| width: 0; | ||
| } | ||
|
|
||
| .maskedContent { | ||
| position: relative; | ||
| } | ||
|
|
||
| .fullFrame { | ||
| inset: 0; | ||
| overflow: hidden; | ||
| position: absolute; | ||
| } | ||
|
|
||
| /* Move mask to edge */ | ||
| .edgeBottom { | ||
| transform: translateY(calc(100cqh - var(--masked-edge-size))); | ||
| } | ||
|
|
||
| .edgeRight { | ||
| transform: translateX(calc(100cqw - var(--masked-edge-size))); | ||
| } | ||
|
|
||
| .maskImage { | ||
| transform-box: fill-box; | ||
| transform-origin: center; | ||
| } | ||
|
|
||
| .mirrorX { | ||
| transform: scaleX(-1); | ||
| } | ||
|
|
||
| .mirrorY { | ||
| transform: scaleY(-1); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| import type { CSSProperties, ReactNode } from "react" | ||
| import type { Meta, StoryObj } from "@storybook/react" | ||
|
|
||
| import { MaskedEdge } from "./masked-edge" | ||
|
|
||
| const pageStyle: CSSProperties = { | ||
| background: "#e6f5ff", | ||
| backgroundImage: 'url("/masked-edge-demo/rpg-fight-bg.gif")', | ||
| backgroundSize: "cover", | ||
| display: "flex", | ||
| flexWrap: "wrap", | ||
| padding: 32, | ||
| width: "fit-content", | ||
| } | ||
|
|
||
| const cardStyle: CSSProperties = { | ||
| background: "#bb3eac", | ||
| color: "#fff", | ||
| maxWidth: 460, | ||
| padding: "88px 40px", | ||
| } | ||
|
|
||
| const narrowCardStyle: CSSProperties = { | ||
| ...cardStyle, | ||
| maxWidth: 560, | ||
| padding: "32px 72px", | ||
| } | ||
|
|
||
| const framePanelStyle: CSSProperties = { | ||
| display: "flex", | ||
| flexDirection: "column", | ||
| } | ||
|
|
||
| function CardContent() { | ||
| return ( | ||
| <> | ||
| <h3 style={{ margin: "0 0 8px" }}>A masked edge</h3> | ||
| <p style={{ margin: 0 }}> | ||
| Use opaque artwork to cut out the edges of the container. | ||
| </p> | ||
| </> | ||
| ) | ||
| } | ||
|
|
||
| function Scene({ children }: { children: ReactNode }) { | ||
| return <div style={pageStyle}>{children}</div> | ||
| } | ||
|
|
||
| const meta: Meta<typeof MaskedEdge> = { | ||
| component: MaskedEdge, | ||
| title: "components/masked-edge", | ||
| } | ||
|
|
||
| export default meta | ||
|
|
||
| type Story = StoryObj<typeof MaskedEdge> | ||
|
|
||
| export const Top: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <MaskedEdge top="/masked-edge-demo/crumb-border.svg" size={30} style={cardStyle}> | ||
| <CardContent /> | ||
| </MaskedEdge> | ||
| </Scene> | ||
| ), | ||
| } | ||
|
|
||
| export const Bottom: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <MaskedEdge | ||
| bottom="/masked-edge-demo/crumb-border.svg" | ||
| mirror | ||
| size={30} | ||
| style={cardStyle} | ||
| > | ||
| <CardContent /> | ||
| </MaskedEdge> | ||
| </Scene> | ||
| ), | ||
| } | ||
|
|
||
| export const TopAndBottomMirror: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <MaskedEdge | ||
| image="/masked-edge-demo/crumb-border.svg" | ||
| sides="top bottom" | ||
| mirror | ||
| size={30} | ||
| style={cardStyle} | ||
| > | ||
| <CardContent /> | ||
| </MaskedEdge> | ||
| </Scene> | ||
| ), | ||
| } | ||
|
|
||
| export const TopAndBottom: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <MaskedEdge | ||
| top="/masked-edge-demo/crumb-border.svg" | ||
| bottom="/masked-edge-demo/crumb-border-bottom.png" | ||
| size={30} | ||
| style={cardStyle} | ||
| > | ||
| <CardContent /> | ||
| </MaskedEdge> | ||
| </Scene> | ||
| ), | ||
| } | ||
|
|
||
| export const Right: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <MaskedEdge | ||
| right="/masked-edge-demo/edge-pattern-bite-vertical.png" | ||
| mirror | ||
| size={80} | ||
| style={narrowCardStyle} | ||
| > | ||
| <CardContent /> | ||
| <p> | ||
| One asset set on the right and mirrored to flip it the desired direction. Repeat | ||
| is not set, therefore the masked asset will stretch. | ||
| </p> | ||
| </MaskedEdge> | ||
| </Scene> | ||
| ), | ||
| } | ||
|
|
||
| export const LeftAndRight: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <MaskedEdge | ||
| image="/masked-edge-demo/edge-pattern-bite-vertical.png" | ||
| sides="left right" | ||
| mirror | ||
| size={80} | ||
| style={narrowCardStyle} | ||
| > | ||
| <CardContent /> | ||
| <p> | ||
| One asset set to the left and right, mirrored. They will stretch to the ends of | ||
| the container if <u>repeat</u> is not set to tile the asset. | ||
| </p> | ||
| </MaskedEdge> | ||
| </Scene> | ||
| ), | ||
| } | ||
|
|
||
| export const Repeat: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <MaskedEdge | ||
| image="/masked-edge-demo/edge-pattern.png" | ||
| sides="top bottom" | ||
| repeat | ||
| tileSize={100} | ||
| size={40} | ||
| mirror | ||
| style={{ ...cardStyle, padding: 100 }} | ||
| > | ||
| <CardContent /> | ||
| <p> | ||
| A pattern set to the top and bottom edge and repeating. We can adjust the tile | ||
| size or limit to a single side. | ||
| </p> | ||
| </MaskedEdge> | ||
| </Scene> | ||
| ), | ||
| } | ||
|
|
||
| export const FullFrame169: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <div style={{ maxWidth: 500, width: "40vw" }}> | ||
| <MaskedEdge image="/masked-edge-demo/frame-16-9.png" fullFrame> | ||
| <div style={framePanelStyle}> | ||
| <img src="/masked-edge-demo/water-animated.gif" alt="" /> | ||
| </div> | ||
| </MaskedEdge> | ||
| </div> | ||
| </Scene> | ||
| ), | ||
| } | ||
|
|
||
| export const FullFrame11: Story = { | ||
| render: () => ( | ||
| <Scene> | ||
| <div style={{ maxWidth: 400, width: "40vw" }}> | ||
| <MaskedEdge image="/masked-edge-demo/frame-1-1.png" fullFrame frameAspect="1 / 1"> | ||
| <div style={framePanelStyle}> | ||
| <img src="/masked-edge-demo/animated-1-1.gif" alt="" /> | ||
| </div> | ||
| </MaskedEdge> | ||
| </div> | ||
| </Scene> | ||
| ), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a few linting issues due to the
nameproperty being used on some of these stories. Let's clean those up and see if we can get CI to pass.