-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
910 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
apps/docs/app/ui/components/breakpointTable/BreakpointTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use client"; | ||
|
||
import SimpleTable from "../simpleTable/SimpleTable"; | ||
import { Breakpoints } from "@hopper-ui/components"; | ||
|
||
export default function BreakpointTable() { | ||
const breakpoints = Object.entries(Breakpoints).map(([key, value]) => { | ||
return { | ||
name: key, | ||
value: `min-width: ${value}px` | ||
}; | ||
}); | ||
|
||
return ( | ||
<SimpleTable | ||
aria-label="Breakpoints" | ||
headers={["Name", "Media query"]} | ||
data={[ | ||
{ name: "base", value: "min-width: 0px" }, | ||
...breakpoints | ||
]} | ||
/> | ||
); | ||
} |
36 changes: 21 additions & 15 deletions
36
apps/docs/app/ui/components/componentExample/ComponentPreviewWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import clsx from "clsx"; | ||
|
||
interface SimpleTableProps { | ||
"aria-label"?: string; | ||
headers: string[]; | ||
data: object[]; | ||
lastColumnAlignment?: "left" | "right"; | ||
} | ||
|
||
export default async function SimpleTable({ "aria-label": ariaLabel, headers, data, lastColumnAlignment }: SimpleTableProps) { | ||
return ( | ||
<table aria-label={ariaLabel} className="hd-table"> | ||
<thead> | ||
<tr> | ||
{headers.map((header, index) => { | ||
const classNames = clsx("hd-table__column", { "hd-table__colum--right": index === headers.length - 1 && lastColumnAlignment === "right" }); | ||
|
||
return ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<th key={index} className={classNames}> | ||
{header} | ||
</th> | ||
); | ||
})} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{data.map((row, rowIndex) => { | ||
return ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<tr key={rowIndex} className="hd-table__row"> | ||
{ | ||
Object.entries(row).map(([key, value], index) => { | ||
const classNames = clsx("hd-table__cell", { "hd-table__cell--right": index === headers.length - 1 && lastColumnAlignment === "right" }); | ||
|
||
return ( | ||
<td key={key} className={classNames}> | ||
{value} | ||
</td> | ||
); | ||
}) | ||
} | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,43 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import Callout from "./Callout.tsx"; | ||
import { Callout } from "./Callout.tsx"; | ||
|
||
const meta = { | ||
title: "components/Callout", | ||
component: Callout | ||
component: Callout, | ||
args: { | ||
children: "Content of the callout" | ||
} | ||
} satisfies Meta<typeof Callout>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: {} | ||
}; | ||
|
||
export const Warning: Story = { | ||
args: { | ||
children: "Content of the callout" | ||
variant: "warning" | ||
} | ||
}; | ||
|
||
export const Success: Story = { | ||
args: { | ||
variant: "success" | ||
} | ||
}; | ||
|
||
export const Error: Story = { | ||
args: { | ||
variant: "error" | ||
} | ||
}; | ||
|
||
export const Message: Story = { | ||
args: { | ||
variant: "message" | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,50 @@ | ||
import type { ReactNode } from "react"; | ||
"use client"; | ||
|
||
import { createContext, type ForwardedRef, forwardRef, type ReactNode } from "react"; | ||
import { type ContextValue, useContextProps } from "react-aria-components"; | ||
import clsx from "clsx"; | ||
|
||
import { Icon, WarningIcon, CheckIcon, ErrorIcon, InfoIcon, MessageIcon } from "@/components/icon"; | ||
|
||
import "./callout.css"; | ||
|
||
export interface CalloutProps { | ||
children: ReactNode; | ||
className?: string; | ||
variant?: "information" | "success" | "warning" | "error" | "message"; | ||
} | ||
|
||
const Callout = ({ children }: CalloutProps) => { | ||
function Callout(props: CalloutProps, ref: ForwardedRef<HTMLDivElement>) { | ||
[props, ref] = useContextProps(props, ref, CalloutContext); | ||
const { children, className, variant = "information", ...other } = props; | ||
|
||
const iconMap = { | ||
information: InfoIcon, | ||
success: CheckIcon, | ||
warning: WarningIcon, | ||
error: ErrorIcon, | ||
message: MessageIcon | ||
}; | ||
|
||
const IconSrc = iconMap[variant] || InfoIcon; | ||
|
||
return ( | ||
<div className="hd-callout"> | ||
<div {...other} | ||
className={clsx("hd-callout", className, { | ||
[`hd-callout--${variant}`]: variant | ||
})} | ||
ref={ref} | ||
role="alert" | ||
> | ||
<Icon className="hd-callout__icon" src={IconSrc} /> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
} | ||
|
||
export const CalloutContext = createContext<ContextValue<Partial<CalloutProps>, HTMLDivElement>>({}); | ||
|
||
const _Callout = forwardRef<HTMLDivElement, CalloutProps>(Callout); | ||
_Callout.displayName = "Callout"; | ||
|
||
export default Callout; | ||
export { _Callout as Callout }; |
Oops, something went wrong.