From eb17ae6dd70b92b650dc6f4a1c28185e99bcce4d Mon Sep 17 00:00:00 2001 From: Luca Goslar <47827429+lucagoslar@users.noreply.github.com> Date: Fri, 20 Jan 2023 16:15:11 +0100 Subject: [PATCH 1/3] docs: typescript and css preprocessor usage --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f00ae1e..e2f281f 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,44 @@ import { styleChildComponent } from "svelte-preprocess-style-child-component"; } ``` +### Depending on a CSS preprocessor (e.g. Sass) + +```shell +npm i -D svelte-sequential-preprocessor svelte-preprocess-style-child-component +``` + +```js +import seqPreprocessor from 'svelte-sequential-preprocessor'; +import { styleChildComponent } from "svelte-preprocess-style-child-component"; +... +{ + preprocess: seqPreprocessor([preprocess(), styleChildComponent()]), // Ensure styleChildComponent is called after the CSS preprocessor +} +``` + +## Typescript + +Create a Typescript declaration file and reference it in your `tsconfig.json`. + +```ts +// e.g. ./types/svelte-preprocess-style-child-component.d.ts + +declare namespace svelteHTML { + interface HTMLAttributes { + part?: string | boolean; + } +} +``` + +> **Warning** +> If modifying your `tsconfig.json`, objects are merged, but arrays are overwritten. Thus, it is necessary to manually merge files and directories referenced in `./.svelte-kit/tsconfig.json`. + +```json +{ + "include": ["./types/**/*.d.ts"] +} +``` + ## Additional features ### Class selector @@ -116,8 +154,8 @@ It transforms component selectors to global selectors, and passes down the class ⬇️ ```html -
-

Child component!

+
+

Child component!

``` @@ -148,7 +186,8 @@ It transforms component selectors to global selectors, and passes down the class import Child from "./Child.svelte"; - + +``` + +For more information on [layering](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer), see the MDN Web Docs. + ### Depending on a CSS preprocessor (e.g. Sass) ```shell