diff --git a/README.md b/README.md index 475b5ea..e30dfd1 100644 --- a/README.md +++ b/README.md @@ -91,13 +91,17 @@ If not using Tailwind, you may also add these styles directly to the `css` secti ## Tailwind usage -If you want, also install the Tailwind preset (for colors, spacings, etc.) and plugin (for typography classes, etc.): +If you’re using RIS UI with Tailwind, you need to add the RIS UI Tailwind preset (for colors, spacings, etc.) and plugin (for typography classes, etc.) ```diff // tailwind.config.js + import { RisUiPreset, RisUiPlugin } from "@digitalservicebund/ris-ui/tailwind"; export default { + content: [ ++ "./node_modules/@digitalservicebund/ris-ui/dist/**/*.{js,vue,ts}", + ], + + presets: [RisUiPreset], + plugins: [RisUiPlugin], @@ -105,6 +109,13 @@ If you want, also install the Tailwind preset (for colors, spacings, etc.) and p }; ``` +##### Additional Configuration for Tailwind Projects + +- Avoid importing `@digitalservicebund/ris-ui/primevue/style.css` in `main.ts` to prevent duplicate styles. +- Include the path to the RIS-UI files in the content array of your Tailwind config to ensure all necessary classes are generated. + +##### Important Note for Nuxt Projects + To avoid issues with conflicting `@layer` directives, make sure to integrate the `postcss-import` module in your PostCSS configuration: See https://tailwindcss.com/docs/adding-custom-styles#using-multiple-css-files diff --git a/src/primevue/dialog/dialog.css b/src/primevue/dialog/dialog.css deleted file mode 100644 index e7dc837..0000000 --- a/src/primevue/dialog/dialog.css +++ /dev/null @@ -1,5 +0,0 @@ -.ris-dialog-content { - svg:first-child { - flex: none; - } -} diff --git a/src/primevue/dialog/dialog.ts b/src/primevue/dialog/dialog.ts index 31d9981..29b29da 100644 --- a/src/primevue/dialog/dialog.ts +++ b/src/primevue/dialog/dialog.ts @@ -1,6 +1,5 @@ import { tw } from "@/lib/tags"; import { DialogPassThroughOptions } from "primevue/dialog"; -import "./dialog.css"; const dialog: DialogPassThroughOptions = { root: () => { @@ -36,7 +35,7 @@ const dialog: DialogPassThroughOptions = { // (for example) by the confirm dialog. If the svg is not the first child, // we assume that it is used in the context of some other layout and don't // apply extra styling. - class: tw`ris-dialog-content overflow-auto has-[svg:first-child]:flex has-[svg:first-child]:gap-8`, + class: tw`ris-dialog-content overflow-auto has-[svg:first-child]:flex has-[svg:first-child]:gap-8 [&>svg:first-child]:flex-none`, }, footer: { diff --git a/src/primevue/inputText/inputText.css b/src/primevue/inputText/inputText.css deleted file mode 100644 index 5549884..0000000 --- a/src/primevue/inputText/inputText.css +++ /dev/null @@ -1,7 +0,0 @@ -input + small { - @apply ris-label3-regular mt-2 flex items-center gap-4 text-gray-900; -} - -input[aria-invalid="true"] + small { - @apply text-red-900; -} diff --git a/src/primevue/inputText/inputText.ts b/src/primevue/inputText/inputText.ts index 79d906d..eee6ed3 100644 --- a/src/primevue/inputText/inputText.ts +++ b/src/primevue/inputText/inputText.ts @@ -1,9 +1,8 @@ import { tw } from "@/lib/tags"; import { InputTextPassThroughOptions } from "primevue/inputtext"; -import "./inputText.css"; // Base -export const base = tw`border-2 border-blue-800 bg-white outline-4 -outline-offset-4 outline-blue-800 placeholder:text-gray-800 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`; +export const base = tw`border-2 border-blue-800 bg-white outline-4 -outline-offset-4 outline-blue-800 [&+small]:ris-label3-regular placeholder:text-gray-800 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 [&+small]:mt-4 [&+small]:flex [&+small]:items-center [&+small]:gap-4 [&+small]:text-gray-900 [&[aria-invalid="true"]+small]:text-red-900`; // Sizes export const small = tw`ris-body2-regular h-48 px-16 py-4`; diff --git a/src/primevue/select/select.css b/src/primevue/select/select.css deleted file mode 100644 index baf5286..0000000 --- a/src/primevue/select/select.css +++ /dev/null @@ -1,7 +0,0 @@ -div + small { - @apply ris-label3-regular mt-4 flex items-center gap-4 text-gray-900; -} - -div[aria-invalid="true"] + small { - @apply text-red-900; -} diff --git a/src/primevue/select/select.ts b/src/primevue/select/select.ts index 649bd1e..4c33c31 100644 --- a/src/primevue/select/select.ts +++ b/src/primevue/select/select.ts @@ -1,11 +1,10 @@ import { tw } from "@/lib/tags.ts"; import { SelectPassThroughOptions } from "primevue/select"; -import "./select.css"; const select: SelectPassThroughOptions = { root: ({ props, state }) => { // Base - const base = tw`ris-body2-regular inline-flex h-48 items-center justify-between border-2 bg-white py-4 pl-16 pr-12 outline-4 -outline-offset-4`; + const base = tw`ris-body2-regular inline-flex h-48 items-center justify-between border-2 bg-white py-4 pl-16 pr-12 outline-4 -outline-offset-4 [&+small]:ris-label3-regular [&+small]:mt-2 [&+small]:flex [&+small]:items-center [&+small]:gap-4 [&+small]:text-gray-900 [&[aria-invalid="true"]+small]:text-red-900`; // States const normal = tw`cursor-pointer border-blue-800 outline-blue-800`; diff --git a/src/primevue/textarea/textarea.css b/src/primevue/textarea/textarea.css deleted file mode 100644 index df0f79f..0000000 --- a/src/primevue/textarea/textarea.css +++ /dev/null @@ -1,7 +0,0 @@ -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.ts b/src/primevue/textarea/textarea.ts index a0f12e9..68918a9 100644 --- a/src/primevue/textarea/textarea.ts +++ b/src/primevue/textarea/textarea.ts @@ -1,11 +1,10 @@ import { tw } from "@/lib/tags"; import { TextareaPassThroughOptions } from "primevue/textarea"; -import "./textarea.css"; const textarea: TextareaPassThroughOptions = { root: ({ props }) => { // Base - const base = tw`ris-body1-regular min-h-56 border-2 border-blue-800 bg-white px-14 pb-12 pt-8 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`; + const base = tw`ris-body1-regular min-h-56 border-2 border-blue-800 bg-white px-14 pb-12 pt-8 outline-4 -outline-offset-4 outline-blue-800 [&+small]:ris-label3-regular 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 [&+small]:mt-2 [&+small]:flex [&+small]:items-center [&+small]:gap-4 [&+small]:text-gray-900 [&[aria-invalid="true"]+small]:text-red-900`; // Integration for primevue/fluid const fluid = tw`w-full`;