Skip to content

Commit

Permalink
fix: toggle styles (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
YaGRRusso authored Mar 18, 2024
1 parent fd9cbe2 commit 0467112
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 13 additions & 14 deletions package/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import LayoutDefault from './layout/Default'
import { Form, Input } from './library'
import { Form, Toggle } from './library'

import { zodResolver } from '@hookform/resolvers/zod'
import { Envelope, Eraser } from '@phosphor-icons/react'
import { Alien, Eraser } from '@phosphor-icons/react'
import { useState } from 'react'
import { SubmitHandler, useForm } from 'react-hook-form'
import { z } from 'zod'
Expand Down Expand Up @@ -44,18 +44,17 @@ function App() {
<Form.Root onSubmit={handleSubmit(onSubmit)}>
{/* ================================= TEST AREA ================================= */}

<Form.Group>
<Form.Label>
<Envelope />
Email
</Form.Label>
{/* === children === */}
<Input.Root>
<Input.Input />
</Input.Root>
{/* === children === */}
<Form.Message status="alert">{errors.data?.message}</Form.Message>
</Form.Group>
<div className="w-156">
<Toggle.Root type="multiple" expanded>
<Toggle.Item
icon={<Alien />}
value="a"
text="text a"
notification
/>
<Toggle.Item value="b" text="text b" />
</Toggle.Root>
</div>

{/* ================================= TEST AREA ================================= */}
</Form.Root>
Expand Down
16 changes: 9 additions & 7 deletions package/src/library/Toggle/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ const ToggleItem: FC<ToggleItemProps> = forwardRef<
<Item
ref={ref}
className={cn(
'group/item flex flex-1 items-center justify-center gap-2 px-4 py-2 first:rounded-l-lg last:rounded-r-lg data-[state="on"]:bg-primary-200 data-[state="on"]:text-primary',
'group/item flex flex-1 items-center justify-center gap-2 p-2 text-sm first:rounded-l-lg last:rounded-r-lg data-[state="on"]:bg-primary-200 data-[state="on"]:text-primary',
className,
)}
{...rest}
>
<div className="relative">
{icon}
{notification && (
<div className="absolute -right-1 -top-1 h-2 w-2 rounded-full border border-error-300 bg-error-400" />
)}
</div>
{icon && (
<div className="relative">
{icon}
{notification && (
<div className="absolute -right-1 -top-1 h-2 w-2 animate-pulse rounded-full border border-error-300 bg-error-400" />
)}
</div>
)}
<span className='max-w-full overflow-hidden text-ellipsis whitespace-nowrap group-aria-[expanded="true"]:hidden group-data-[state="on"]/item:!block'>
{text}
</span>
Expand Down

0 comments on commit 0467112

Please sign in to comment.