From 5031d0b40e2768f629e6d2a8f778b9a2f114fd2b Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 24 Mar 2024 09:30:32 +1100 Subject: [PATCH] feat(layer): first pass at `Layer` component (#1932) Closes #1892 --- COMPONENT_INDEX.md | 23 +++++++++++++- docs/src/COMPONENT_API.json | 47 ++++++++++++++++++++++++++++- docs/src/pages/components/Layer.svx | 16 ++++++++++ src/Layer/Layer.svelte | 37 +++++++++++++++++++++++ src/Layer/index.js | 1 + src/index.js | 1 + tests/Layer.test.svelte | 13 ++++++++ types/Layer/Layer.svelte.d.ts | 27 +++++++++++++++++ types/index.d.ts | 1 + 9 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 docs/src/pages/components/Layer.svx create mode 100644 src/Layer/Layer.svelte create mode 100644 src/Layer/index.js create mode 100644 tests/Layer.test.svelte create mode 100644 types/Layer/Layer.svelte.d.ts diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 8422cfb730..dc43739790 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -1,6 +1,6 @@ # Component Index -> 165 components exported from carbon-components-svelte@1.0.0-next.1. +> 166 components exported from carbon-components-svelte@1.0.0-next.1. ## Components @@ -66,6 +66,7 @@ - [`ImageLoader`](#imageloader) - [`InlineLoading`](#inlineloading) - [`InlineNotification`](#inlinenotification) +- [`Layer`](#layer) - [`Link`](#link) - [`ListBox`](#listbox) - [`ListBoxField`](#listboxfield) @@ -1959,6 +1960,26 @@ None. | mouseenter | forwarded | -- | | mouseleave | forwarded | -- | +## `Layer` + +### Props + +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :--------- | :------- | :--------------- | :------- | ------------------------------------------------------------ | ---------------------- | --------------------------------------------------------------------------- | +| level | No | let | Yes | 0 | 1 | 2 | undefined | Specify the layer level to override any existing levels based on hierarchy. | +| as | No | let | No | string | "div" | Specify the HTML element to render. | +| layerProps | No | let | No | import('svelte/elements').HTMLElementAttributes | {} | Specify the Layer HTML element props | + +### Slots + +| Slot name | Default | Props | Fallback | +| :-------- | :------ | :---- | :------- | +| -- | Yes | -- | -- | + +### Events + +None. + ## `Link` ### Props diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index 5784378254..60018cc2bd 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -1,5 +1,5 @@ { - "total": 165, + "total": 166, "components": [ { "moduleName": "Accordion", @@ -5754,6 +5754,51 @@ "typedefs": [], "rest_props": { "type": "Element", "name": "div" } }, + { + "moduleName": "Layer", + "filePath": "src/Layer/Layer.svelte", + "props": [ + { + "name": "level", + "kind": "let", + "description": "Specify the layer level to override any existing levels based on hierarchy.", + "type": "0 | 1 | 2 ", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": true + }, + { + "name": "as", + "kind": "let", + "description": "Specify the HTML element to render.", + "type": "string", + "value": "\"div\"", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "layerProps", + "kind": "let", + "description": "Specify the Layer HTML element props", + "type": "import('svelte/elements').HTMLElementAttributes", + "value": "{}", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + } + ], + "moduleExports": [], + "slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }], + "events": [], + "typedefs": [] + }, { "moduleName": "Link", "filePath": "src/Link/Link.svelte", diff --git a/docs/src/pages/components/Layer.svx b/docs/src/pages/components/Layer.svx new file mode 100644 index 0000000000..f4cd6493b4 --- /dev/null +++ b/docs/src/pages/components/Layer.svx @@ -0,0 +1,16 @@ + + +## Default + + +

First layer

+ +

Second layer

+ +

Third layer

+
+
+
\ No newline at end of file diff --git a/src/Layer/Layer.svelte b/src/Layer/Layer.svelte new file mode 100644 index 0000000000..70ba493740 --- /dev/null +++ b/src/Layer/Layer.svelte @@ -0,0 +1,37 @@ + + + + + diff --git a/src/Layer/index.js b/src/Layer/index.js new file mode 100644 index 0000000000..da3ecb27f8 --- /dev/null +++ b/src/Layer/index.js @@ -0,0 +1 @@ +export { default as Layer } from "./Layer.svelte"; diff --git a/src/index.js b/src/index.js index aa378cb15e..6763f0cc43 100644 --- a/src/index.js +++ b/src/index.js @@ -58,6 +58,7 @@ export { FormLabel } from "./FormLabel"; export { Grid, Row, Column } from "./Grid"; export { ImageLoader } from "./ImageLoader"; export { InlineLoading } from "./InlineLoading"; +export { Layer } from "./Layer"; export { Link, OutboundLink } from "./Link"; export { ListBox, diff --git a/tests/Layer.test.svelte b/tests/Layer.test.svelte new file mode 100644 index 0000000000..d5f7feba46 --- /dev/null +++ b/tests/Layer.test.svelte @@ -0,0 +1,13 @@ + + + +

First layer

+ +

Second layer

+ +

Third layer

+
+
+
diff --git a/types/Layer/Layer.svelte.d.ts b/types/Layer/Layer.svelte.d.ts new file mode 100644 index 0000000000..3c98d64e7f --- /dev/null +++ b/types/Layer/Layer.svelte.d.ts @@ -0,0 +1,27 @@ +import type { SvelteComponentTyped } from "svelte"; + +export interface LayerProps { + /** + * Specify the layer level to override any existing levels based on hierarchy. + * @default undefined + */ + level?: 0 | 1 | 2; + + /** + * Specify the HTML element to render. + * @default "div" + */ + as?: string; + + /** + * Specify the Layer HTML element props + * @default {} + */ + layerProps?: import("svelte/elements").HTMLElementAttributes; +} + +export default class Layer extends SvelteComponentTyped< + LayerProps, + Record, + { default: {} } +> {} diff --git a/types/index.d.ts b/types/index.d.ts index 0d31321d84..dcb0e56c93 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -64,6 +64,7 @@ export { default as Row } from "./Grid/Row.svelte"; export { default as Column } from "./Grid/Column.svelte"; export { default as ImageLoader } from "./ImageLoader/ImageLoader.svelte"; export { default as InlineLoading } from "./InlineLoading/InlineLoading.svelte"; +export { default as Layer } from "./Layer/Layer.svelte"; export { default as Link } from "./Link/Link.svelte"; export { default as OutboundLink } from "./Link/OutboundLink.svelte"; export { default as ListBox } from "./ListBox/ListBox.svelte";