-
Notifications
You must be signed in to change notification settings - Fork 5
React/topic #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React/topic #47
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from "./topic.component"; | ||
| export * from "./subtopic.component"; | ||
| export * from "./topic.types"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { Badge } from "../badge"; | ||
| import { Level } from "../level"; | ||
| import { ButtonHTMLAttributes } from "react"; | ||
| import { TopicElement } from "./topic.types"; | ||
| import { withAs } from "@/utils/hoc"; | ||
|
|
||
| type SubTopicProps = TopicElement & ButtonHTMLAttributes<HTMLButtonElement>; | ||
|
|
||
| export const SubTopic = withAs( | ||
| (Component, { level, state, title, ...rest }: SubTopicProps) => { | ||
| return ( | ||
| <Component {...rest} tabIndex={0} className="rustlanges-subtopic"> | ||
| <Level variant={level} /> | ||
| <span className="rustlanges-subtopic__title">{title}</span> | ||
| <Badge type="default" variant={state} /> | ||
| </Component> | ||
| ); | ||
| } | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { PropsWithChildren } from "react"; | ||
| import { ArrowDown } from "@/icons"; | ||
| import { Badge } from "../badge"; | ||
| import { Level } from "../level"; | ||
| import { TopicElement } from "./topic.types"; | ||
|
|
||
| type TopicProps = PropsWithChildren & TopicElement; | ||
| export const Topic = ({ level, title, state, children }: TopicProps) => { | ||
| return ( | ||
| <details className="rustlanges-topic"> | ||
| <summary className="rustlanges-topic__summary"> | ||
| <Level as="span" variant={level} /> | ||
| <span className="text-h6 rustlanges-topic__title">{title}</span> | ||
| <Badge type="default" variant={state} /> | ||
| <ArrowDown /> | ||
| </summary> | ||
| {children} | ||
| </details> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { BadgeVariants } from "../badge/badge.const"; | ||
| import { LevelVariants } from "../level/level.const"; | ||
|
|
||
| export type TopicElement = { | ||
| level: LevelVariants; | ||
| title: string; | ||
| state: BadgeVariants; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| @layer component { | ||
| .rustlanges-topic { | ||
| @apply w-full; | ||
| } | ||
| .rustlanges-topic[open] svg { | ||
| @apply -rotate-180; | ||
| } | ||
|
|
||
| .rustlanges-topic__summary::-webkit-details-marker { | ||
Brayan-724 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| display: none; | ||
| } | ||
|
|
||
| .rustlanges-topic__summary { | ||
| @apply grid w-full grid-cols-[auto_1fr_auto_auto] items-center gap-2 border-y border-black px-3 py-4; | ||
| @apply [&>svg]:duration-400 [&>svg]:size-6 [&>svg]:transition; | ||
|
||
| } | ||
|
|
||
| .rustlanges-topic__title { | ||
| @apply text-neutral-950 dark:text-neutral-50; | ||
| } | ||
|
|
||
| .rustlanges-subtopic { | ||
| @apply grid w-full grid-cols-[auto_1fr_auto] items-center gap-2 border-b px-6 py-2.5; | ||
| @apply border-b-gray dark:border-b-neutral-600; | ||
| } | ||
|
|
||
| .rustlanges-subtopic__title { | ||
| @apply text-neutral-950; | ||
| @apply desktop:text-sm text-xs; | ||
| @apply dark:text-neutral-50; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.