-
Notifications
You must be signed in to change notification settings - Fork 70
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
1 parent
c1fee14
commit 6bf834b
Showing
4 changed files
with
16 additions
and
50 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,27 +1,11 @@ | ||
import { mergeProps, splitProps } from 'solid-js' | ||
import { Dynamic } from 'solid-js/web' | ||
import { css, cx } from 'styled-system/css' | ||
import { type HTMLStyledProps, splitCssProps } from 'styled-system/jsx' | ||
import type { ComponentProps } from 'solid-js' | ||
import { styled } from 'styled-system/jsx' | ||
import { type TextVariantProps, text } from 'styled-system/recipes' | ||
import type { StyledComponent } from 'styled-system/types' | ||
|
||
type As = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | ||
type TextProps = TextVariantProps & { as?: React.ElementType } | ||
|
||
export type HeadingProps = TextVariantProps & { | ||
as?: As | ||
} & HTMLStyledProps<As> | ||
|
||
export const Heading = (props: HeadingProps) => { | ||
const mergedProps = mergeProps({ as: 'h2' }, props) | ||
const [variantProps, headingProps] = splitProps(mergedProps, ['size']) | ||
const [cssProps, elementProps] = splitCssProps(headingProps) | ||
const [localProps, rootProps] = splitProps(elementProps, ['as', 'class']) | ||
const className = text({ variant: 'heading', size: variantProps.size }) | ||
|
||
return ( | ||
<Dynamic | ||
component={localProps.as} | ||
class={cx(className, css(cssProps), localProps.class)} | ||
{...rootProps} | ||
/> | ||
) | ||
} | ||
export type HeadingProps = ComponentProps<typeof Heading> | ||
export const Heading = styled('h2', text, { | ||
defaultProps: { variant: 'heading' }, | ||
}) as StyledComponent<'h2', TextProps> |
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,27 +1,9 @@ | ||
import type { Assign, HTMLArkProps } from '@ark-ui/solid' | ||
import { mergeProps, splitProps } from 'solid-js' | ||
import { Dynamic } from 'solid-js/web' | ||
import { css, cx } from 'styled-system/css' | ||
import { splitCssProps } from 'styled-system/jsx' | ||
import type { ComponentProps } from 'solid-js' | ||
import { styled } from 'styled-system/jsx' | ||
import { type TextVariantProps, text } from 'styled-system/recipes' | ||
import type { JsxStyleProps } from 'styled-system/types' | ||
import type { StyledComponent } from 'styled-system/types' | ||
|
||
export interface TextProps extends Assign<JsxStyleProps, HTMLArkProps<'p'>>, TextVariantProps { | ||
as?: 'p' | 'label' | 'div' | 'span' | ||
} | ||
type ParagraphProps = TextVariantProps & { as?: JSX.ElementType } | ||
|
||
export const Text = (props: TextProps) => { | ||
const mergedProps = mergeProps({ as: 'p' }, props) | ||
const [variantProps, textProps] = splitProps(mergedProps, ['size', 'variant']) | ||
const [cssProps, elementProps] = splitCssProps(textProps) | ||
const [localProps, rootProps] = splitProps(elementProps, ['as', 'class']) | ||
const className = text(variantProps) | ||
|
||
return ( | ||
<Dynamic | ||
component={localProps.as} | ||
class={cx(className, css(cssProps), localProps.class)} | ||
{...rootProps} | ||
/> | ||
) | ||
} | ||
export type TextProps = ComponentProps<typeof Text> | ||
export const Text = styled('p', text) as StyledComponent<'p', ParagraphProps> |
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