Skip to content

Commit

Permalink
feat: add Label component
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandredev3 committed Oct 14, 2022
1 parent 02926f1 commit c2172cc
Show file tree
Hide file tree
Showing 12 changed files with 232 additions and 7 deletions.
1 change: 1 addition & 0 deletions .storybook/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-a11y",
{
name: "@storybook/addon-postcss",
options: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"playground": "pnpm --filter @tails-ui/playground dev"
},
"devDependencies": {
"@storybook/addon-a11y": "^6.5.12",
"@storybook/addon-essentials": "^6.5.12",
"@storybook/addon-interactions": "^6.5.12",
"@storybook/addon-links": "^6.5.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/Checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@tails-ui/styles": "*",
"@tails-ui/typography": "*",
"@tails-ui/label": "*",
"@radix-ui/react-slot": "^1.0.0",
"@radix-ui/react-checkbox": "^1.0.0",
"clsx": "^1.2.1",
Expand Down
8 changes: 5 additions & 3 deletions packages/components/Checkbox/stories/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta, StoryObj } from "@storybook/react";
import { Checks } from 'phosphor-react';
import { Typography } from "@tails-ui/typography";
import { Label } from "@tails-ui/label";

import { Checkbox, type CheckboxRootProps } from "../src/Checkbox";

Expand All @@ -11,6 +11,8 @@ export default {
children: (
<Checkbox.Icon />
),
id: 'terms',
name: 'terms'
},
argTypes: {
children: {
Expand All @@ -23,9 +25,9 @@ export default {
(Story) => (
<div className="flex items-center gap-2">
{Story()}
<Typography size="sm">
<Label htmlFor="terms" className="text-sm">
Accept terms & conditions
</Typography>
</Label>
</div>
)
]
Expand Down
34 changes: 34 additions & 0 deletions packages/components/Label/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@tails-ui/label",
"version": "1.0.0",
"description": "",
"main": "src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"peerDependencies": {
"react": ">=17",
"react-dom": ">=17"
},
"dependencies": {
"@tails-ui/styles": "*",
"@tails-ui/text-input": "*",
"phosphor-react": "^1.4.1",
"clsx": "^1.2.1"
},
"devDependencies": {
"@tails-ui/eslint-config": "*",
"@tails-ui/typings": "*",
"@tails-ui/tsconfig": "*",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"autoprefixer": "^10.4.12",
"eslint": "^7.32.0",
"postcss": "^8.4.18",
"react": "^18.2.0",
"tailwindcss": "^3.1.8"
}
}
6 changes: 6 additions & 0 deletions packages/components/Label/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
16 changes: 16 additions & 0 deletions packages/components/Label/src/Label.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { LabelHTMLAttributes } from "react";
import { clsx } from "clsx";
import { CommonComponentProps } from "@tails-ui/typings";

export type LabelProps = CommonComponentProps &
LabelHTMLAttributes<HTMLLabelElement>;

export function Label({ children, className, ...rest }: LabelProps) {
return (
<label className={clsx(className, "text-gray-100 font-sans")} {...rest}>
{children}
</label>
);
}

Label.displayName = "Label"
3 changes: 3 additions & 0 deletions packages/components/Label/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '@tails-ui/styles/common.css';

export { Label, type LabelProps } from "./Label";
42 changes: 42 additions & 0 deletions packages/components/Label/stories/Label.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Meta, StoryObj } from "@storybook/react";
import { TextInput } from "@tails-ui/text-input";
import { Envelope } from 'phosphor-react'

import { Label, type LabelProps } from "../src/Label";

export default {
title: "Components / Label",
component: Label,
args: {
children: "Lorem ipsum",
}
} as Meta<LabelProps>;

export const Default: StoryObj<LabelProps> = {};

export const InputLabel: StoryObj<LabelProps> = {
args: {
children: "E-mail address",
htmlFor: "email",
className: "mb-3 text-4 text-gray-100"
},
decorators: [
(Story) => (
<div className="flex flex-col">
{Story()}
<TextInput>
<TextInput.Icon>
<Envelope />
</TextInput.Icon>

<TextInput.Input
type="email"
placeholder="[email protected]"
name="email"
id="email"
/>
</TextInput>
</div>
),
],
};
7 changes: 7 additions & 0 deletions packages/components/Label/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'**/*.tsx'
],
plugins: [require('@tails-ui/styles/plugin')]
}
16 changes: 16 additions & 0 deletions packages/components/Label/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "@tails-ui/tsconfig/client.json",
"compilerOptions": {
"types": [
"react"
]
},
"include": [
"."
],
"exclude": [
"dist",
"build",
"node_modules"
]
}
103 changes: 100 additions & 3 deletions pnpm-lock.yaml

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

0 comments on commit c2172cc

Please sign in to comment.