diff --git a/src/primevue/index.ts b/src/primevue/index.ts index 5aad540..26dc9f7 100644 --- a/src/primevue/index.ts +++ b/src/primevue/index.ts @@ -5,6 +5,7 @@ import inputGroup from "./inputGroup/inputGroup"; import inputGroupAddon from "./inputGroup/inputGroupAddon"; import inputText from "./inputText/inputText"; import password from "./password/password"; +import textarea from "./textarea/textarea"; export const RisUiTheme = { button, @@ -12,4 +13,5 @@ export const RisUiTheme = { inputGroup, inputGroupAddon, password, + textarea, }; diff --git a/src/primevue/textarea/textarea.css b/src/primevue/textarea/textarea.css new file mode 100644 index 0000000..df0f79f --- /dev/null +++ b/src/primevue/textarea/textarea.css @@ -0,0 +1,7 @@ +textarea + small { + @apply ris-label3-regular mt-2 flex items-center gap-4 text-gray-900; +} + +textarea[aria-invalid="true"] + small { + @apply text-red-900; +} diff --git a/src/primevue/textarea/textarea.stories.ts b/src/primevue/textarea/textarea.stories.ts new file mode 100644 index 0000000..09ced24 --- /dev/null +++ b/src/primevue/textarea/textarea.stories.ts @@ -0,0 +1,118 @@ +import { html } from "@/lib/tags"; +import { Meta, StoryObj } from "@storybook/vue3"; +import PrimevueTextarea from "primevue/textarea"; +import ErrorOutline from "~icons/ic/error-outline"; + +// Imported as Btn because somehow formatting sometimes changes +// "PrimevueTextarea" to "PrimevueTextarea", breaking the stories +const meta: Meta = { + component: PrimevueTextarea, + + tags: ["autodocs"], + + args: { + autoResize: true, + disabled: false, + fluid: false, + placeholder: "Placeholder", + readonly: false, + value: "Text", + invalid: false, + }, +}; + +export default meta; + +export const Default: StoryObj = { + render: (args) => ({ + components: { PrimevueTextarea }, + setup() { + return { args }; + }, + template: html``, + }), +}; + +export const WithLabelAndHint: StoryObj = { + render: (args) => ({ + components: { PrimevueTextarea }, + setup() { + return { args }; + }, + template: html` +
+ + + Additional hint text +
+ `, + }), +}; + +export const Disabled: StoryObj = { + args: { + disabled: true, + }, + render: (args) => ({ + components: { PrimevueTextarea }, + setup() { + return { args }; + }, + template: html``, + }), +}; + +export const Readonly: StoryObj = { + args: { + readonly: true, + }, + render: (args) => ({ + components: { PrimevueTextarea }, + setup() { + return { args }; + }, + template: html``, + }), +}; + +export const Invalid: StoryObj = { + args: { + invalid: true, + }, + render: (args) => ({ + components: { PrimevueTextarea, ErrorOutline }, + setup() { + return { args }; + }, + template: html` +
+ + + + Error message with helper text goes here + +
+ `, + }), +}; + +export const FluidProp: StoryObj = { + args: { + fluid: true, + }, + render: (args) => ({ + components: { PrimevueTextarea }, + setup() { + return { args }; + }, + template: html``, + }), +}; diff --git a/src/primevue/textarea/textarea.ts b/src/primevue/textarea/textarea.ts new file mode 100644 index 0000000..c33a9d1 --- /dev/null +++ b/src/primevue/textarea/textarea.ts @@ -0,0 +1,22 @@ +import { tw } from "@/lib/tags"; +import { TextareaPassThroughOptions } from "primevue/textarea"; +import "./textarea.css"; + +const textarea: TextareaPassThroughOptions = { + root: ({ props }) => { + // Base + const base = tw`ris-body2-regular h-48 border-2 border-blue-800 bg-white px-16 py-10 outline-4 -outline-offset-4 outline-blue-800 placeholder:text-gray-900 read-only:cursor-not-allowed read-only:border-blue-300 read-only:bg-blue-300 hover:outline focus:outline disabled:border-blue-500 disabled:bg-white disabled:text-blue-500 disabled:outline-none aria-[invalid]:border-red-800 aria-[invalid]:bg-red-200 aria-[invalid]:outline-red-800 aria-[invalid]:disabled:outline-none`; + + // Integration for primevue/fluid + const fluid = tw`w-full`; + + return { + class: { + [base]: true, + [fluid]: !!props.fluid, + }, + }; + }, +}; + +export default textarea;