-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: cleanup identity-placeholder
- Loading branch information
Showing
8 changed files
with
259 additions
and
216 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,41 +1,22 @@ | ||
"use client"; | ||
|
||
import { | ||
identityPlaceholder, | ||
type IdentityPlaceholderVariantProps, | ||
} from "@seed-design/css/recipes/identity-placeholder"; | ||
import clsx from "clsx"; | ||
import { IdentityPlaceholder as SeedIdentityPlaceholder } from "@seed-design/react"; | ||
import * as React from "react"; | ||
|
||
export interface IdentityPlaceholderProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
IdentityPlaceholderVariantProps {} | ||
extends SeedIdentityPlaceholder.RootProps {} | ||
|
||
/** | ||
* @see https://v3.seed-design.io/docs/react/components/identity-placeholder | ||
*/ | ||
export const IdentityPlaceholder = React.forwardRef< | ||
HTMLDivElement, | ||
IdentityPlaceholderProps | ||
>(({ className, identity = "person", ...otherProps }, ref) => { | ||
const classNames = identityPlaceholder({ identity }); | ||
>((props, ref) => { | ||
return ( | ||
<div ref={ref} className={clsx(classNames.root, className)} {...otherProps}> | ||
<svg | ||
className={classNames.image} | ||
viewBox="0 0 640 640" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
role="img" | ||
aria-label="Identity placeholder" | ||
> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M481 301c0 56-29 106-72 135a264 264 0 0 1 175 248c0 18-118 38-264 38S56 702 56 684c0-114 73-211 174-248a162 162 0 1 1 251-135Zm-203-1c8 0 14-9 14-20s-6-20-14-20-15 9-15 20 7 20 15 20Zm83 0c8 0 15-9 15-20s-7-20-15-20-15 9-15 20 7 20 15 20Zm-88 25c4-2 9-1 11 4 4 7 15 19 36 19s32-12 36-19a8 8 0 1 1 15 8c-7 12-23 27-51 27s-44-15-50-27c-3-5-1-10 3-12Z" | ||
/> | ||
</svg> | ||
</div> | ||
<SeedIdentityPlaceholder.Root {...props} ref={ref}> | ||
<SeedIdentityPlaceholder.Image /> | ||
</SeedIdentityPlaceholder.Root> | ||
); | ||
}); | ||
IdentityPlaceholder.displayName = "IdentityPlaceholder"; |
6 changes: 6 additions & 0 deletions
6
packages/react/src/components/IdentityPlaceholder/IdentityPlaceholder.namespace.ts
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,6 @@ | ||
export { | ||
IdentityPlaceholderRoot as Root, | ||
IdentityPlaceholderImage as Image, | ||
type IdentityPlaceholderRootProps as RootProps, | ||
type IdentityPlaceholderImageProps as ImageProps, | ||
} from "./IdentityPlaceholder"; |
47 changes: 47 additions & 0 deletions
47
packages/react/src/components/IdentityPlaceholder/IdentityPlaceholder.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,47 @@ | ||
import { | ||
identityPlaceholder, | ||
type IdentityPlaceholderVariantProps, | ||
} from "@seed-design/css/recipes/identity-placeholder"; | ||
import { mergeProps } from "@seed-design/dom-utils"; | ||
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive"; | ||
import * as React from "react"; | ||
import { createStyleContext } from "../../utils/createStyleContext"; | ||
|
||
const { useClassNames, withProvider } = createStyleContext(identityPlaceholder); | ||
|
||
export interface IdentityPlaceholderRootProps | ||
extends IdentityPlaceholderVariantProps, | ||
PrimitiveProps, | ||
React.HTMLAttributes<HTMLDivElement> {} | ||
|
||
export const IdentityPlaceholderRoot = withProvider<HTMLDivElement, IdentityPlaceholderRootProps>( | ||
Primitive.div, | ||
"root", | ||
); | ||
|
||
export interface IdentityPlaceholderImageProps extends React.SVGProps<SVGSVGElement> {} | ||
|
||
export const IdentityPlaceholderImage = React.forwardRef< | ||
SVGSVGElement, | ||
IdentityPlaceholderImageProps | ||
>((props, ref) => { | ||
const classNames = useClassNames(); | ||
return ( | ||
<svg | ||
ref={ref} | ||
viewBox="0 0 640 640" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
role="img" | ||
aria-label="Identity placeholder" | ||
{...mergeProps({ className: classNames.image }, props)} | ||
> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M481 301c0 56-29 106-72 135a264 264 0 0 1 175 248c0 18-118 38-264 38S56 702 56 684c0-114 73-211 174-248a162 162 0 1 1 251-135Zm-203-1c8 0 14-9 14-20s-6-20-14-20-15 9-15 20 7 20 15 20Zm83 0c8 0 15-9 15-20s-7-20-15-20-15 9-15 20 7 20 15 20Zm-88 25c4-2 9-1 11 4 4 7 15 19 36 19s32-12 36-19a8 8 0 1 1 15 8c-7 12-23 27-51 27s-44-15-50-27c-3-5-1-10 3-12Z" | ||
/> | ||
</svg> | ||
); | ||
}); | ||
IdentityPlaceholderImage.displayName = "IdentityPlaceholderImage"; |
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,8 @@ | ||
export { | ||
IdentityPlaceholderRoot, | ||
IdentityPlaceholderImage, | ||
type IdentityPlaceholderRootProps, | ||
type IdentityPlaceholderImageProps, | ||
} from "./IdentityPlaceholder"; | ||
|
||
export * as IdentityPlaceholder from "./IdentityPlaceholder.namespace"; |
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