diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index bb2a10b2..8f5b9b07 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -73,6 +73,8 @@ export default defineConfig({ label: "Tips and Tricks", autogenerate: { directory: "contributing/tips-and-tricks" }, }, + "contributing/standard-library", + "contributing/library-modules", ], }, { diff --git a/docs/src/content/docs/contributing/guides/raw-color-values.md b/docs/src/content/docs/contributing/guides/raw-color-values.md index 7926cd83..af1ec6b3 100644 --- a/docs/src/content/docs/contributing/guides/raw-color-values.md +++ b/docs/src/content/docs/contributing/guides/raw-color-values.md @@ -7,16 +7,8 @@ sidebar: ## Obtaining RGB values -You can use the `#lib.rgbify()` utility mixin to get the raw RGB values from a color. - -```less ---ctp-base: #lib.rgbify(@base) []; // -> 30, 30, 46 -``` +See [`#lib.rgbify()`](/contributing/standard-library/#librgbify). ## Obtaining HSL values -You can use the `#lib.hslify()` utility mixin to get the raw HSL values from a color. - -```less ---ctp-base: #lib.hslify(@base) []; // -> 240, 21.052631578947366%, 14.901960784313726% -``` +See [`#lib.hslify()`](/contributing/standard-library/#libhslify). diff --git a/docs/src/content/docs/contributing/library-modules.md b/docs/src/content/docs/contributing/library-modules.md new file mode 100644 index 00000000..b25f3148 --- /dev/null +++ b/docs/src/content/docs/contributing/library-modules.md @@ -0,0 +1,6 @@ +--- +title: Library Modules +description: Reference for library modules. +--- + +Coming soon. diff --git a/docs/src/content/docs/contributing/standard-library.md b/docs/src/content/docs/contributing/standard-library.md new file mode 100644 index 00000000..6e4f9737 --- /dev/null +++ b/docs/src/content/docs/contributing/standard-library.md @@ -0,0 +1,48 @@ +--- +title: Standard Library +description: Reference to using the standard library. +--- + +The standard library is a collection of mixins to simplify and prevent redundant code in userstyles. The source code is at [`lib/lib.less`](https://github.com/catppuccin/userstyles/blob/main/lib/lib.less) and the library is hosted at https://userstyles.catppuccin.com/lib/lib.less. + +In userstyles, the standard library is imported at the top like so (along with other [library modules](/contributing/reference/library/modules/)): + +```less +@import "https://userstyles.catppuccin.com/lib/lib.less"; +``` + +## API + +The standard library exposes a `#lib` namespace. + +### `#lib.palette()` + +The standard library palette mixin provides Less variable definitions for hex colors and CSS filters from the palette. Call the mixin at the top of the `#catppuccin` mixin to inject the variables into the userstyle context. This is used in all userstyles. + +### `#lib.defaults()` + +The standard library defaults mixin provides a set of default styles for text selection and native/input elements. This is generally applied in all userstyles, with some exceptions. + +### `#lib.rgbify()` + +The standard library `rgbify` mixin is a utility mixin for extracting the color in `r, g, b` format from a palette variable. + +#### Examples + +```less +--my-variable-rgb: #lib.rgbify(@base) []; // -> 30, 30, 46 +``` + +### `#lib.hslify()` + +The standard library `hslify` mixin is a utility mixin for extracting the color in `h, s, l` format from a palette variable. + +#### Examples + +```less +--my-variable-hsl: #lib.hslify(@base) []; // -> 240, 21.052631578947366%, 14.901960784313726% +``` + +### `#lib.css-variables()` + +The standard library CSS variables mixin provides the palette variables in [CSS variable/custom property](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_cascading_variables/Using_CSS_custom_properties) form. This is commonly used alongside [syntax highlighting imports](/contributing/guides/syntax-highlighting/).