-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/CardOrganization
- Loading branch information
Showing
8 changed files
with
220 additions
and
16 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
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,24 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Heading } from './index'; | ||
|
||
import { within } from '@storybook/testing-library'; | ||
import { expect } from '@storybook/jest'; | ||
|
||
const meta: Meta<typeof Heading> = { | ||
component: Heading, | ||
title: 'atoms/Heading', | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof Heading>; | ||
|
||
export const Primary = { | ||
args: {}, | ||
}; | ||
|
||
export const Heading: Story = { | ||
args: {}, | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
expect(canvas.getByText(/Welcome to Heading!/gi)).toBeTruthy(); | ||
}, | ||
}; |
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,71 @@ | ||
import * as React from 'react'; | ||
import { Slot } from '@radix-ui/react-slot'; | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
|
||
const headingVariants = cva( | ||
'font-family-inherit m-0', | ||
{ | ||
variants: { | ||
size: { | ||
"1": 'text-1', // h9 | ||
"2": 'text-2', // h8 | ||
"3": 'text-3', // h7 | ||
"4": 'text-4', // h6 | ||
"5": 'text-5', // h5 | ||
"6": 'text-6', // h4 | ||
"7": 'text-7', // h3 | ||
"8": 'text-8', // h2 | ||
"9": 'text-9', // h1 | ||
}, | ||
weight: { | ||
regular: 'font-normal', | ||
medium: 'font-medium', | ||
bold: 'font-bold' | ||
}, | ||
align: { | ||
left: 'text-left', | ||
center: 'text-center', | ||
right: 'text-right', | ||
}, | ||
color: { | ||
primary: 'text-white', | ||
secondary: 'text-gray-500', | ||
}, | ||
}, | ||
defaultVariants: { | ||
size: "1", | ||
weight: 'medium', | ||
align: 'left', | ||
color: 'primary', | ||
}, | ||
} | ||
); | ||
|
||
export interface HeadingProps | ||
extends React.HTMLAttributes<HTMLHeadingElement>, | ||
VariantProps<typeof headingVariants> { | ||
asChild?: boolean; | ||
size?: "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"; | ||
color?: 'primary' | 'secondary'; | ||
align?: 'left' | 'center' | 'right'; | ||
weight?: 'regular' | 'medium' | 'bold'; | ||
} | ||
|
||
const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>( | ||
({ className, size, weight, align, color, asChild = false, children, ...props }, ref) => { | ||
const Comp = asChild ? Slot : 'div'; | ||
return ( | ||
<Comp | ||
className={(headingVariants({ size, weight, align, color, className }))} | ||
ref={ref} | ||
{...props} | ||
> | ||
{children} | ||
</Comp> | ||
); | ||
} | ||
); | ||
|
||
Heading.displayName = 'Heading'; | ||
|
||
export { Heading, headingVariants }; |
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,39 @@ | ||
import * as React from "react" | ||
import { cva, type VariantProps } from "class-variance-authority" | ||
|
||
import { cn } from "@hypha-platform/ui-utils" | ||
|
||
const badgeVariants = cva( | ||
"inline-flex items-center rounded-lg border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", | ||
{ | ||
variants: { | ||
variant: { | ||
default: | ||
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80", | ||
secondary: | ||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", | ||
destructive: | ||
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", | ||
positive: | ||
"border-emerald-300 bg-green-500 text-green-500 bg-opacity-5", | ||
warning: "border-amber-400 bg-orange-400 text-orange-400 bg-opacity-5", | ||
outline: "text-foreground", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
}, | ||
} | ||
) | ||
|
||
export interface BadgeProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof badgeVariants> {} | ||
|
||
function Badge({ className, variant, ...props }: BadgeProps) { | ||
return ( | ||
<div className={cn(badgeVariants({ variant }), className)} {...props} /> | ||
) | ||
} | ||
|
||
export { Badge, badgeVariants } |
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,47 @@ | ||
import * as React from 'react' | ||
import { cva, type VariantProps } from 'class-variance-authority' | ||
import { cn } from '@hypha-platform/ui-utils'; | ||
|
||
const containerVariants = cva('mx-auto px-4 sm:px-6 lg:px-8', { | ||
variants: { | ||
variant: { | ||
fullMobileConstrainedPadded: 'max-w-7xl sm:px-6 lg:px-8', | ||
constrainedPadded: 'max-w-7xl px-4 sm:px-6 lg:px-8', | ||
fullMobileBreakpointPadded: 'container mx-auto sm:px-6 lg:px-8', | ||
breakpointPadded: 'container mx-auto px-4 sm:px-6 lg:px-8', | ||
narrowConstrainedPadded: 'max-w-7xl px-4 sm:px-6 lg:px-8 max-w-3xl', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'narrowConstrainedPadded', | ||
}, | ||
}) | ||
|
||
export interface ContainerProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof containerVariants> { | ||
asChild?: boolean | ||
} | ||
|
||
const Container: React.FC<ContainerProps> = ({ | ||
asChild, | ||
className, | ||
children, | ||
variant, | ||
...props | ||
}) => { | ||
const Comp = asChild ? React.Fragment : 'div' | ||
const containerClasses = cn(containerVariants({ variant }), className) | ||
|
||
return ( | ||
<Comp className={containerClasses} {...props}> | ||
{variant === 'narrowConstrainedPadded' ? ( | ||
<div className="mx-auto max-w-3xl">{children}</div> | ||
) : ( | ||
children | ||
)} | ||
</Comp> | ||
) | ||
} | ||
|
||
export { Container, containerVariants } |
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