-
-
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.
feat: Add px helper function for pixel string conversion, enhance Swi…
…tch component behavior, and update Card and BooleanCard styles
- Loading branch information
Showing
12 changed files
with
151 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
[1026/154037.906:ERROR:crashpad_client_win.cc(810)] not connected | ||
[1031/084040.057:ERROR:crashpad_client_win.cc(810)] not connected | ||
[1031/085527.626:ERROR:crashpad_client_win.cc(810)] not connected | ||
[1031/085529.576:ERROR:crashpad_client_win.cc(810)] not connected |
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: 13 additions & 11 deletions
24
packages/ui/src/components/BooleanCard/LoadingBooleanCard.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 |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import { Card } from '../Card' | ||
import { Switch } from '../Switch' | ||
import { Card } from "../Card" | ||
import { Switch } from "../Switch" | ||
|
||
export const SuggestionLoadingCard = () => { | ||
export const LoadingBooleanCard = () => { | ||
return ( | ||
<li className="opacity-60 animate-pulse"> | ||
<div className="opacity-60 animate-pulse"> | ||
<Card> | ||
<div className="flex justify-between gap-4 w-full"> | ||
<div className="flex justify-between gap-6 w-full"> | ||
<header className="flex flex-col gap-1 w-full"> | ||
<h4 className="bg-secondary/40 w-fit rounded-full text-transparent">lorem pisum lorem</h4> | ||
<h5 className="text-sm w-fit bg-secondary/20 rounded-full text-transparent">lorem pisum lorem epson</h5> | ||
<h4 className="bg-secondary/40 w-fit rounded-full text-transparent"> | ||
lorem pisum lorem | ||
</h4> | ||
<h5 className="text-sm w-fit bg-secondary/20 rounded-full text-transparent"> | ||
lorem pisum lorem epson | ||
</h5> | ||
</header> | ||
|
||
<div> | ||
<Switch disabled checked={false} onChange={() => {}} /> | ||
</div> | ||
<Switch disabled checked={false} onChange={() => {}} /> | ||
</div> | ||
</Card> | ||
</li> | ||
</div> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,60 +1,72 @@ | ||
"use client" | ||
|
||
import type { ComponentProps, FC } from "react" | ||
import React, { type ComponentProps, type FC } from "react" | ||
|
||
import { cn } from "../../helpers" | ||
import { cn, mergeRefs } from "../../helpers" | ||
import { mergeDeep } from "../../helpers/merge-deep/merge-deep" | ||
import { useRipple } from "../../hooks" | ||
import { getTheme } from "../../theme-store" | ||
import type { DeepPartial } from "../../types/types" | ||
import { ButtonProps } from "../Button" | ||
import { FocusEffect } from "../FocusEffect" | ||
import type { CardTheme } from "./theme" | ||
|
||
export type CardProps = ComponentProps<"div"> & | ||
ComponentProps<"button"> & | ||
ComponentProps<"a"> & { | ||
href?: string | ||
Pick<ButtonProps, "rippleOptions"> & { | ||
theme?: DeepPartial<CardTheme> | ||
onClick?: () => void | ||
} | ||
|
||
/** | ||
* @name Card | ||
* | ||
* @description A Card component that can be used to display content in a card-like style. Usefull in a blog, a social network, a forum... | ||
* | ||
* @returns {React.ReactNode} A Card component. | ||
* | ||
* @example | ||
* @example ``` | ||
* <Card> | ||
* <h5 className="text-2xl font-bold">Card title!</h5> | ||
* <p className="font-normal text-secondary-700"> | ||
* Hello there! | ||
* </p> | ||
* </Card> | ||
* ``` | ||
* @returns {React.ReactNode} A Card component. | ||
* | ||
*/ | ||
export const Card: FC<CardProps> = (props): React.ReactNode => { | ||
const { href, theme: customTheme = {}, onClick, ...rest } = props | ||
|
||
// Card component will be an Anchor link if href prop is passed. | ||
|
||
const Component = | ||
typeof onClick === "undefined" | ||
? typeof href === "undefined" | ||
? "div" | ||
: "a" | ||
: "button" | ||
|
||
const theme = mergeDeep(getTheme().card, customTheme) | ||
return ( | ||
<Component | ||
data-testid="ui-card" | ||
href={href} | ||
onClick={onClick} | ||
className={cn(theme.base, href && theme.href, rest?.className)} | ||
{...(rest as any)} | ||
> | ||
{rest.children} | ||
{onClick && <FocusEffect />} | ||
</Component> | ||
) | ||
} | ||
|
||
export const Card = React.forwardRef<React.ElementRef<"div">, CardProps>( | ||
(props, ref) => { | ||
const { theme: customTheme = {}, onClick, className = "", ...rest } = props | ||
|
||
// Card component will be an Anchor link if href prop is passed. | ||
|
||
const Component = typeof onClick === "undefined" ? "div" : "button" | ||
|
||
const theme = mergeDeep(getTheme().card, customTheme) | ||
|
||
const [ripple, event] = useRipple({ | ||
disabled: rest.disabled, | ||
...rest.rippleOptions, | ||
opacity: 0.3, | ||
}) | ||
return ( | ||
<Component | ||
ref={mergeRefs([ripple, ref])} | ||
data-testid="ui-card" | ||
onClick={(e) => { | ||
if (onClick) { | ||
event(e) | ||
onClick(e as React.MouseEvent<HTMLButtonElement>) | ||
} | ||
}} | ||
className={cn(theme.base, className)} | ||
{...(rest as any)} | ||
> | ||
{rest.children} | ||
{onClick && <FocusEffect />} | ||
</Component> | ||
) | ||
} | ||
) |
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,10 +1,7 @@ | ||
export interface CardTheme { | ||
base: string | ||
href: string | ||
} | ||
|
||
export const cardTheme: CardTheme = { | ||
base: "flex flex-col gap-2 rounded-xl bg-secondary/40 gap-2 p-4 group", | ||
|
||
href: "hover:bg-secondary-100 dark:hover:bg-secondary-700", | ||
base: "h-fit flex-col gap-2 rounded-xl bg-secondary-100 dark:bg-secondary-800/80 text-secondary-900 dark:text-secondary-50 shadow gap-2 p-4 group text-left", | ||
} |
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
Oops, something went wrong.