diff --git a/src/components/Flex.tsx b/src/components/Flex.tsx index 4d3a1f15..6940f7a6 100644 --- a/src/components/Flex.tsx +++ b/src/components/Flex.tsx @@ -7,7 +7,7 @@ import { forwardRef, memo, } from 'react' -import { useTheme } from 'styled-components' +import styled, { type DefaultTheme } from 'styled-components' type FlexBaseProps = { /** @@ -45,15 +45,15 @@ type FlexBaseProps = { | 'space-around' | 'space-evenly' - gap?: string - + gap?: keyof DefaultTheme['spacing'] + padding?: keyof DefaultTheme['spacing'] children?: ReactNode } type FlexProps = Omit & FlexBaseProps -function FlexRef(props: FlexProps, ref: Ref) { - const { +function FlexRef( + { direction, wrap, basis, @@ -62,32 +62,69 @@ function FlexRef(props: FlexProps, ref: Ref) { align, justify, gap, + padding, children, ...otherProps - } = props - const theme = useTheme() - + }: FlexProps, + ref: Ref +) { return ( -
{children} -
+ ) } +const FlexSC = styled.div<{ + $direction?: FlexProps['direction'] + $wrap?: FlexProps['wrap'] + $basis?: FlexProps['basis'] + $grow?: FlexProps['grow'] + $shrink?: FlexProps['shrink'] + $align?: FlexProps['align'] + $justify?: FlexProps['justify'] + $gap?: FlexProps['gap'] + $padding?: FlexProps['padding'] +}>( + ({ + theme, + $direction, + $wrap, + $basis, + $grow, + $shrink, + $align, + $justify, + $gap, + $padding, + }) => ({ + display: 'flex', + flexDirection: $direction, + flexWrap: typeof $wrap === 'boolean' ? 'wrap' : $wrap, + flexBasis: $basis, + flexGrow: typeof $grow === 'boolean' ? 1 : $grow, + flexShrink: typeof $shrink === 'boolean' ? 1 : $shrink, + alignItems: $align, + justifyContent: $justify, + gap: theme.spacing[$gap] || 0, + padding: theme.spacing[$padding] || 0, + }) +) + const BaseFlex = forwardRef(FlexRef) const Flex = memo(BaseFlex) diff --git a/src/components/RepositoryCard.tsx b/src/components/RepositoryCard.tsx index f19b9cb4..9948d1f0 100644 --- a/src/components/RepositoryCard.tsx +++ b/src/components/RepositoryCard.tsx @@ -1,4 +1,3 @@ -import { Div, type DivProps, Flex, H1, H3, P, Span } from 'honorable' import { type ComponentProps, type ReactNode, @@ -11,12 +10,13 @@ import styled, { useTheme } from 'styled-components' import Chip from './Chip' import PadlockLockedIcon from './icons/PadlockLockedIcon' import VerifiedIcon from './icons/VerifiedIcon' -import Card from './Card' +import Card, { type CardProps } from './Card' import RocketIcon from './icons/RocketIcon' import AppIcon from './AppIcon' +import Flex from './Flex' -type RepositoryCardProps = DivProps & { +type RepositoryCardProps = CardProps & { title?: string publisher?: string priv?: boolean @@ -107,15 +107,17 @@ function RepositoryCardRef( {featuredLabel && {featuredLabel}} @@ -144,21 +146,16 @@ function RepositoryCardRef( )} -

{title} {!!verified && ( @@ -170,22 +167,19 @@ function RepositoryCardRef( left={4} /> )} -

-

+ {publisher} -

+
@@ -209,25 +203,11 @@ function RepositoryCardRef(
- {description && ( -

- {description} -

- )} -
+ {description && {description}} +
{(trending || tags?.length > 0) && ( @@ -237,12 +217,7 @@ function RepositoryCardRef( hue="lighter" > - - Trending - + Trending )} {tags @@ -265,6 +240,52 @@ function RepositoryCardRef( ) } +const HeaderSC = styled.h1<{ + $variant?: RepositoryCardProps['variant'] + $featuredLabel?: boolean + $size?: RepositoryCardProps['size'] +}>(({ theme, $variant, $featuredLabel, $size }) => ({ + margin: 0, + color: theme.colors.text, + ...($variant === 'marketing' + ? $featuredLabel + ? { ...theme.partials.text.title2 } + : { ...theme.partials.text.subtitle1 } + : $size === 'large' + ? { ...theme.partials.text.title1 } + : { ...theme.partials.text.title2 }), +})) + +const SubheaderSC = styled.h3<{ + $variant?: RepositoryCardProps['variant'] + $featuredLabel?: boolean + $size?: RepositoryCardProps['size'] +}>(({ theme, $variant, $featuredLabel, $size }) => ({ + margin: 0, + ...theme.partials.text.body2, + color: theme.colors['text-xlight'], + marginBottom: $size === 'large' ? theme.spacing.small : 0, + ...($variant === 'marketing' && !$featuredLabel + ? { ...theme.partials.text.caption } + : {}), +})) + +const SpanSC = styled.span(({ theme }) => ({ + color: theme.colors['action-link-inline'], + marginLeft: theme.spacing.xxsmall, +})) + +const DescriptionSC = styled.p(({ theme }) => ({ + ...theme.partials.text.body2, + margin: 0, + marginTop: theme.spacing.xsmall, + color: theme.colors['text-light'], + display: '-webkit-box', + WebkitLineClamp: '2', + WebkitBoxOrient: 'vertical', + overflow: 'hidden', +})) + const RepositoryCard = forwardRef(RepositoryCardRef) export default RepositoryCard