@c2n/header 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Nguyen Thai Vinh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Header
2
+
3
+ A site-shell header that arranges brand, navigation, actions and a mobile trigger without owning navigation state.
4
+
5
+ ```bash
6
+ npm install @c2n/header
7
+ ```
8
+
9
+ ```html
10
+ <script type="module">
11
+ import '@c2n/header'
12
+ </script>
13
+
14
+ <c2-header sticky blurred>
15
+ <strong slot="brand">Northstar</strong>
16
+ <a href="/markets">Markets</a>
17
+ <button slot="actions">Sign in</button>
18
+ </c2-header>
19
+ ```
package/dist/header.js ADDED
@@ -0,0 +1,48 @@
1
+ import { LitElement, html, unsafeCSS } from "lit";
2
+ import { property } from "lit/decorators.js";
3
+ import { customElement } from "@c2n/core/element-helper.js";
4
+ //#region src/header.scss?inline
5
+ var header_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: block;\n}\n\n:host([sticky]) {\n position: sticky;\n z-index: 10;\n top: var(--c2-header--sticky-top,0px);\n}\n\n.c2-header {\n display: flex;\n min-height: var(--c2-header--min-height,64px);\n box-sizing: border-box;\n align-items: center;\n gap: var(--c2-header--gap,24px);\n padding: var(--c2-header--padding,8px 24px);\n color: var(--c2-header--color,#18181b);\n background: var(--c2-header--background,#ffffff);\n border-bottom: var(--c2-header--border-bottom,1px solid #e4e4e7);\n box-shadow: var(--c2-header--box-shadow,none);\n}\n\n:host([blurred]) .c2-header {\n background: var(--c2-header__blurred--background,rgba(255, 255, 255, 0.82));\n backdrop-filter: var(--c2-header--backdrop-filter,blur(16px));\n}\n\n.brand,\n.actions {\n display: flex;\n align-items: center;\n}\n\n.brand {\n flex: 0 0 auto;\n gap: var(--c2-header__brand--gap,8px);\n}\n\n.navigation {\n display: flex;\n min-width: 0;\n flex: 1 1 auto;\n align-items: center;\n}\n\n.actions {\n margin-inline-start: auto;\n gap: var(--c2-header__actions--gap,8px);\n}\n\n.mobile-trigger {\n display: flex;\n align-items: center;\n}";
6
+ //#endregion
7
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
8
+ function __decorate(decorators, target, key, desc) {
9
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
13
+ }
14
+ //#endregion
15
+ //#region src/header.ts
16
+ var Header = class Header extends LitElement {
17
+ constructor(..._args) {
18
+ super(..._args);
19
+ this.sticky = false;
20
+ this.blurred = false;
21
+ this.navigationLabel = "Primary";
22
+ }
23
+ static {
24
+ this.styles = unsafeCSS(header_default);
25
+ }
26
+ render() {
27
+ return html`
28
+ <header class="c2-header" part="header">
29
+ <div class="brand" part="brand"><slot name="brand"></slot></div>
30
+ <nav class="navigation" part="navigation" aria-label=${this.navigationLabel}><slot></slot></nav>
31
+ <div class="actions" part="actions"><slot name="actions"></slot></div>
32
+ <div class="mobile-trigger" part="mobile-trigger"><slot name="mobile-trigger"></slot></div>
33
+ </header>
34
+ `;
35
+ }
36
+ };
37
+ __decorate([property({
38
+ type: Boolean,
39
+ reflect: true
40
+ })], Header.prototype, "sticky", void 0);
41
+ __decorate([property({
42
+ type: Boolean,
43
+ reflect: true
44
+ })], Header.prototype, "blurred", void 0);
45
+ __decorate([property({ attribute: "navigation-label" })], Header.prototype, "navigationLabel", void 0);
46
+ Header = __decorate([customElement("c2-header")], Header);
47
+ //#endregion
48
+ export { Header };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@c2n/header",
3
+ "version": "0.0.7",
4
+ "type": "module",
5
+ "main": "dist/header.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./types/src/header.d.ts",
9
+ "default": "./dist/header.js"
10
+ },
11
+ "./react": {
12
+ "types": "./react.d.ts",
13
+ "default": "./react.js"
14
+ },
15
+ "./vue": {
16
+ "types": "./vue.d.ts",
17
+ "default": "./vue.js"
18
+ },
19
+ "./custom-elements.json": "./custom-elements.json"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "types",
24
+ "react.d.ts",
25
+ "react.js",
26
+ "vue.d.ts",
27
+ "vue.js"
28
+ ],
29
+ "keywords": [
30
+ "header",
31
+ "web component",
32
+ "lit"
33
+ ],
34
+ "license": "MIT",
35
+ "author": "code2nguyen@gmail.com",
36
+ "publishConfig": {
37
+ "registry": "https://registry.npmjs.org",
38
+ "access": "public"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/code2nguyen/web-components.git"
43
+ },
44
+ "scripts": {
45
+ "dev": "vite",
46
+ "build": "wireit",
47
+ "build:only": "vite build",
48
+ "type-check": "wireit"
49
+ },
50
+ "wireit": {
51
+ "type-check": {
52
+ "dependencies": [
53
+ "../../core:build"
54
+ ],
55
+ "command": "tsc -p tsconfig.lib.json --composite false"
56
+ },
57
+ "build": {
58
+ "dependencies": [
59
+ "type-check"
60
+ ],
61
+ "command": "vite build"
62
+ }
63
+ },
64
+ "dependencies": {
65
+ "@c2n/core": "0.0.7",
66
+ "lit": "3.3.3"
67
+ },
68
+ "devDependencies": {
69
+ "@c2n/config": "*"
70
+ },
71
+ "customElements": "custom-elements.json",
72
+ "gitHead": "c8db398a27f7cd417d665fdf5da455fee2d4e910"
73
+ }
package/react.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // JSX types for the custom elements of @c2n/header. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/header/react'
6
+ //
7
+ // Register the elements at module scope before React renders, or React writes an object prop as an
8
+ // attribute and it stringifies.
9
+
10
+ import type { DetailedHTMLProps, HTMLAttributes } from 'react'
11
+ import type { Header } from '@c2n/header'
12
+
13
+ /** Standard React host-element attributes plus the element's own public properties. */
14
+ type C2Props<T> = DetailedHTMLProps<HTMLAttributes<T>, T> & Partial<Omit<T, keyof HTMLElement>>
15
+
16
+ declare module 'react' {
17
+ namespace JSX {
18
+ interface IntrinsicElements {
19
+ 'c2-header': C2Props<Header>
20
+ }
21
+ }
22
+ }
23
+
24
+ export {}
package/react.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}
@@ -0,0 +1,39 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * A site-header shell that arranges branding, navigation, actions and an optional mobile trigger. Navigation behaviour
4
+ * remains the responsibility of slotted controls such as `c2-navigation-menu`.
5
+ *
6
+ * @tag c2-header
7
+ * @slot brand - Logo, product name or home link.
8
+ * @slot - Primary navigation.
9
+ * @slot actions - Account and application actions aligned to the end.
10
+ * @slot mobile-trigger - Responsive navigation trigger, placed after the actions.
11
+ * @cssproperty {pixel} [--c2-header--min-height=64px]
12
+ * @cssproperty {padding} [--c2-header--padding=8px 24px]
13
+ * @cssproperty {pixel} [--c2-header--gap=24px]
14
+ * @cssproperty {color} [--c2-header--background=#ffffff]
15
+ * @cssproperty {color} [--c2-header--color=#18181b]
16
+ * @cssproperty {border} [--c2-header--border-bottom=1px solid #e4e4e7]
17
+ * @cssproperty {box-shadow} [--c2-header--box-shadow=none]
18
+ * @cssproperty {pixel} [--c2-header--sticky-top=0px]
19
+ * @cssproperty {backdrop-filter} [--c2-header--backdrop-filter=blur(16px)]
20
+ * @cssproperty {color} [--c2-header__blurred--background=rgba(255, 255, 255, 0.82)]
21
+ * @cssproperty {pixel} [--c2-header__brand--gap=8px]
22
+ * @cssproperty {pixel} [--c2-header__actions--gap=8px]
23
+ */
24
+ export declare class Header extends LitElement {
25
+ static styles: import("lit").CSSResult;
26
+ /** Pins the header to the configured top offset. */
27
+ sticky: boolean;
28
+ /** Uses a translucent background and backdrop filter. */
29
+ blurred: boolean;
30
+ /** Accessible name for the primary navigation landmark. */
31
+ navigationLabel: string;
32
+ render(): import("lit-html").TemplateResult<1>;
33
+ }
34
+ declare global {
35
+ interface HTMLElementTagNameMap {
36
+ 'c2-header': Header;
37
+ }
38
+ }
39
+ //# sourceMappingURL=header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../src/header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAA;AAKjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,MAAO,SAAQ,UAAU;IACpC,OAAgB,MAAM,0BAAoB;IAE1C,oDAAoD;IACR,MAAM,UAAQ;IAE1D,yDAAyD;IACb,OAAO,UAAQ;IAE3D,2DAA2D;IACd,eAAe,SAAY;IAE/D,MAAM;CAUhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,MAAM,CAAA;KACpB;CACF"}
package/vue.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // Vue template types for the custom elements of @c2n/header. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/header/vue'
6
+ //
7
+ // Tell the compiler about the tags as well, or every c2-* tag is resolved as a Vue component and renders
8
+ // nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
9
+
10
+ import type { DefineComponent, HTMLAttributes } from 'vue'
11
+ import type { Header } from '@c2n/header'
12
+
13
+ /** The element's own public properties, plus every attribute Vue understands on a host element. */
14
+ type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
15
+
16
+ declare module 'vue' {
17
+ interface GlobalComponents {
18
+ 'c2-header': DefineComponent<
19
+ C2Props<Header> & {
20
+ 'navigation-label'?: unknown
21
+ }
22
+ >
23
+ }
24
+ }
25
+
26
+ declare module '@vue/runtime-dom' {
27
+ interface HTMLAttributes {
28
+ /** Vue's own definition omits it, and slotting a plain element into a component needs it. */
29
+ slot?: string
30
+ }
31
+ }
32
+
33
+ export {}
package/vue.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}