Skip to content
Closed
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
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.
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.
13 changes: 13 additions & 0 deletions packages/wethegit-components/src/components/index.tsx
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

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './breakpoint-snipe'

Check failure on line 1 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './breakpoint-snipe'
export * from "./flex"

Check failure on line 2 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './flex'

Check failure on line 2 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './flex'
export * from "./grid-layout"

Check failure on line 3 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './grid-layout'

Check failure on line 3 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './grid-layout'
export * from "./icon"

Check failure on line 4 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './icon'

Check failure on line 4 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './icon'
export * from "./image-group"

Check failure on line 5 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './image-group'

Check failure on line 5 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './image-group'
export * from "./in-view"

Check failure on line 6 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './in-view'

Check failure on line 6 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './in-view'
export * from "./modal"

Check failure on line 7 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './modal'

Check failure on line 7 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './modal'
export * from "./navigation"
export * from "./scalloped-edge"

Check failure on line 9 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './scalloped-edge'

Check failure on line 9 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './scalloped-edge'
export * from "./tag"

Check failure on line 10 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './tag'

Check failure on line 10 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unable to resolve path to module './tag'
export * from "./text"

Check failure on line 11 in packages/wethegit-components/src/components/index.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module './text'
export * from "./visually-hidden"
export * from "./visually-hidden-links"
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { Meta } from "@storybook/blocks"

<Meta title="components/scalloped-edge/Readme" />

# ScallopedEdge

Use a mask to cut a decorative edge from the container's side.
Where the edge art is opaque, the container is cut out.

## Install

```bash
npx @wethegit/components-cli add scalloped-edge
```

## Usage

### Top

Pass an image to `top`, optionally update `size` to taste [default size = 40px].

Also works for the other 3 sides, `bottom`, `left`, `right`

```tsx
<ScallopedEdge top="/images/crumb-border.svg" size="30px">
...
</ScallopedEdge>
```

### Top and Bottom / Left and Right - Mirror

Pass one `image`, define `sides`, then add `mirror` to have the opposite edge inherit and mirror the image.

If you want the edge art to repeat, add `repeat`, then `tileSize` to control size of tiling.

Omitting `repeat` and `tileSize` will stretch image 100% to match edge length.

```tsx
<ScallopedEdge
image="/images/tiled-border.svg"
sides="top bottom"
mirror
repeat
tileSize="75px"
>
...
</ScallopedEdge>
```

`sides` accepts `top bottom`, `left right`, and `all`. When `image` is provided with no defined sides, it defaults to all four sides.

### Top and Bottom / Left and Right - Unique

Pass an image path to `top`, `bottom`, `left`, or `right`. Can be combined or a single entry.

```tsx
<ScallopedEdge top="/images/crumb-border.svg" bottom="/images/crumb-border-bottom.png">
...
</ScallopedEdge>
```

```tsx
<ScallopedEdge left="/images/crumb-border-vertical.svg" size="100px">
...
</ScallopedEdge>
```

### Full frame

`fullFrame` maps your `image` over the whole `frameAspect` box (16:9 by default).

```tsx
<ScallopedEdge image="/images/frame-1x1.svg" fullFrame frameAspect="1 / 1">
<img src="images/video-1x1.gif" alt="" />
</ScallopedEdge>
```

## Notes

- SVG artwork that needs to stretch should set `preserveAspectRatio="none"`.
- The artwork is used as a mask: opaque areas are cut away and transparent
areas stay visible.
- `mirror` is ignored by `fullFrame`.
- `size` is the thickness of each edge container.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.scallopedEdge {
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;
}

.scallopedContent {
position: relative;
}

.fullFrame {
inset: 0;
overflow: hidden;
position: absolute;
}

/* Move mask to edge */
.edgeBottom {
transform: translateY(calc(100cqh - var(--scallop-edge-size)));
}

.edgeRight {
transform: translateX(calc(100cqw - var(--scallop-edge-size)));
}

.maskImage {
transform-box: fill-box;
transform-origin: center;
}

.mirrorX {
transform: scaleX(-1);
}

.mirrorY {
transform: scaleY(-1);
}

/*
Support is widely available (Fallback if subtract is not supported)
https://caniuse.com/mdn-css_properties_mask-composite_subtract
*/

@supports not (mask-composite: subtract) {
.masked {
mask-image: linear-gradient(#000, #000) !important;
mask-position: 0 0 !important;
mask-repeat: no-repeat !important;
mask-size: 100% 100% !important;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
import type { CSSProperties, ReactNode } from "react"
import type { Meta, StoryObj } from "@storybook/react"

import { ScallopedEdge } from "./scalloped-edge"

const pageStyle: CSSProperties = {
background: "#e6f5ff",
backgroundImage: 'url("/scalloped-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 ScallopedEdge> = {
component: ScallopedEdge,
title: "components/scalloped-edge",
}

export default meta

type Story = StoryObj<typeof ScallopedEdge>

export const Top: Story = {
name: "Top",

Check warning on line 59 in packages/wethegit-components/src/components/scalloped-edge/scalloped-edge.stories.tsx

View workflow job for this annotation

GitHub Actions / Lint

Named exports should not use the name annotation if it is redundant to the name that would be generated by the export name

Check warning on line 59 in packages/wethegit-components/src/components/scalloped-edge/scalloped-edge.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

Named exports should not use the name annotation if it is redundant to the name that would be generated by the export name
render: () => (
<Scene>
<ScallopedEdge
top="/scalloped-edge-demo/crumb-border.svg"
size="30px"
style={cardStyle}
>
<CardContent />
</ScallopedEdge>
</Scene>
),
}

export const Bottom: Story = {
name: "Bottom",

Check warning on line 74 in packages/wethegit-components/src/components/scalloped-edge/scalloped-edge.stories.tsx

View workflow job for this annotation

GitHub Actions / Lint

Named exports should not use the name annotation if it is redundant to the name that would be generated by the export name

Check warning on line 74 in packages/wethegit-components/src/components/scalloped-edge/scalloped-edge.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

Named exports should not use the name annotation if it is redundant to the name that would be generated by the export name
render: () => (
<Scene>
<ScallopedEdge
bottom="/scalloped-edge-demo/crumb-border.svg"
mirror
size="30px"
style={cardStyle}
>
<CardContent />
</ScallopedEdge>
</Scene>
),
}

export const TopAndBottomMirror: Story = {
name: "Top and Bottom - Mirrored",
render: () => (
<Scene>
<ScallopedEdge
image="/scalloped-edge-demo/crumb-border.svg"
sides="top bottom"
mirror
size="30px"
style={cardStyle}
>
<CardContent />
</ScallopedEdge>
</Scene>
),
}

export const TopAndBottom: Story = {
name: "Top and Bottom - Unique",
render: () => (
<Scene>
<ScallopedEdge
top="/scalloped-edge-demo/crumb-border.svg"
bottom="/scalloped-edge-demo/crumb-border-bottom.png"
size="30px"
style={cardStyle}
>
<CardContent />
</ScallopedEdge>
</Scene>
),
}

export const Right: Story = {
name: "Right",

Check warning on line 123 in packages/wethegit-components/src/components/scalloped-edge/scalloped-edge.stories.tsx

View workflow job for this annotation

GitHub Actions / Lint

Named exports should not use the name annotation if it is redundant to the name that would be generated by the export name

Check warning on line 123 in packages/wethegit-components/src/components/scalloped-edge/scalloped-edge.stories.tsx

View workflow job for this annotation

GitHub Actions / lint

Named exports should not use the name annotation if it is redundant to the name that would be generated by the export name
render: () => (
<Scene>
<ScallopedEdge
right="/scalloped-edge-demo/edge-pattern-vertical.png"
mirror
repeat
tileSize="100px"
style={narrowCardStyle}
>
<CardContent />
<p>
When we want the container taller, we can add more text. When we want the
container taller, we can add more text. When we want the container taller, we
can add more text.
</p>
</ScallopedEdge>
</Scene>
),
}

export const LeftAndRight: Story = {
name: "Left and right",
render: () => (
<Scene>
<ScallopedEdge
image="/scalloped-edge-demo/edge-pattern-vertical.png"
sides="left right"
mirror
repeat
tileSize="100px"
size="40px"
style={narrowCardStyle}
>
<CardContent />
<p>
When we want the container taller, we can add more text. When we want the
container taller, we can add more text. When we want the container taller, we
can add more text.
</p>
</ScallopedEdge>
</Scene>
),
}

export const Repeat: Story = {
name: "Repeat and tile",
render: () => (
<Scene>
<ScallopedEdge
image="/scalloped-edge-demo/edge-pattern.png"
sides="top bottom"
repeat
tileSize="100px"
size="40px"
mirror
style={{ ...cardStyle, padding: 100 }}
>
<CardContent />
</ScallopedEdge>
</Scene>
),
}

export const FullFrame169: Story = {
name: "Full frame 16:9",
render: () => (
<Scene>
<div style={{ maxWidth: 500, width: "40vw" }}>
<ScallopedEdge image="/scalloped-edge-demo/frame-16-9.png" fullFrame>
<div style={framePanelStyle}>
<img src="/scalloped-edge-demo/water-animated.gif" alt="" />
</div>
</ScallopedEdge>
</div>
</Scene>
),
}

export const FullFrame11: Story = {
name: "Full frame 1:1",
render: () => (
<Scene>
<div style={{ maxWidth: 400, width: "40vw" }}>
<ScallopedEdge
image="/scalloped-edge-demo/frame-1-1.png"
fullFrame
frameAspect="1 / 1"
>
<div style={framePanelStyle}>
<img src="/scalloped-edge-demo/animated-1-1.gif" alt="" />
</div>
</ScallopedEdge>
</div>
</Scene>
),
}
Loading
Loading