Skip to content

Commit

Permalink
fix: helper text story
Browse files Browse the repository at this point in the history
  • Loading branch information
ArpitaGanatra committed Jul 2, 2024
1 parent 1088575 commit 5167158
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 15 deletions.
42 changes: 42 additions & 0 deletions apps/docs/src/stories/HelperText.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react'
import { HelperText } from '@squaress/ui/helper-text'
import type { Meta, StoryFn } from '@storybook/react'

export default {
title: 'Components/HelperText',
component: HelperText,
argTypes: {
variant: {
control: { type: 'select', options: ['default', 'success', 'error'] },
},
show: {
control: { type: 'boolean' },
},
children: {
control: { type: 'text' },
},
},
} as Meta<typeof HelperText>

const Template: StoryFn = (args) => <HelperText {...args} />

export const Default = Template.bind({})
Default.args = {
variant: 'default',
show: true,
children: 'This is a default helper text.',
}

export const Success = Template.bind({})
Success.args = {
variant: 'success',
show: true,
children: 'This is a success helper text.',
}

export const Error = Template.bind({})
Error.args = {
variant: 'error',
show: true,
children: 'This is an error helper text.',
}
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@squaress/ui",
"version": "0.0.68",
"version": "0.0.69",
"description": "",
"main": "lib/index.js",
"module": "lib/index.mjs",
Expand Down
20 changes: 6 additions & 14 deletions packages/ui/src/components/helper-text/helper-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { cn } from '@utils/cn'
import { Text } from '../text/text'
import type { VariantProps } from 'class-variance-authority'

export const helperTextVariants = cva('transition-colors', {
export const helperTextVariants = cva('', {
variants: {
variant: {
default: 'text-[var(--color-fg-primary-base)]',
success: 'text-[var(--color-fg-positive-base)]',
error: 'text-[var(--color-fg-negative-base)]',
default: '!text-[var(--color-fg-primary-base)]',
success: '!text-[var(--color-fg-positive-base)]',
error: '!text-[var(--color-fg-negative-base)]',
},
},
})
Expand All @@ -23,7 +23,7 @@ type TextProps = React.HTMLAttributes<HTMLElement> &
export const HelperText = forwardRef<HTMLElement | null, TextProps>(
({ className, children, variant = 'default', show }) => {
const id = uuidV4()

console.log('variant', variant)
return (
<AnimatePresence>
{show && (
Expand All @@ -39,15 +39,7 @@ export const HelperText = forwardRef<HTMLElement | null, TextProps>(
damping: 30,
}}
>
<Text
className={cn(
helperTextVariants({
variant,
}),
className,
'l2',
)}
>
<Text className={cn(helperTextVariants({ variant }), className, 'l2')}>
{children}
</Text>
</motion.div>
Expand Down

0 comments on commit 5167158

Please sign in to comment.