From 48287e64cab880c8d39e459aacc7869e3d2c2e23 Mon Sep 17 00:00:00 2001 From: Carlo Barone Date: Mon, 29 Jan 2024 16:52:21 +0100 Subject: [PATCH] feat: collapsible tab card --- package-lock.json | 6 + package.json | 1 + src/cosmoz-tab-card.js | 138 +++++++++++++++------- src/utils.js | 55 +++++---- stories/cosmoz-tab-card.stories.js | 182 ++++++++++++++++++----------- 5 files changed, 240 insertions(+), 142 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75193c5..72c7aa0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "8.0.0", "license": "Apache-2.0", "dependencies": { + "@neovici/cosmoz-collapse": "^1.3.0", "@neovici/cosmoz-router": "^11.0.0", "@neovici/cosmoz-utils": "^6.0.0", "@pionjs/pion": "^2.0.0", @@ -3327,6 +3328,11 @@ "typescript": "^5.1.0" } }, + "node_modules/@neovici/cosmoz-collapse": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@neovici/cosmoz-collapse/-/cosmoz-collapse-1.3.0.tgz", + "integrity": "sha512-m+FMz2WW9RYrkBILNA5EE+CDTvo+YqxR7fvZb62Qab9bFScJwTxk/DbmMEL/Dsawr76YjrIfX76Z5DcvEZ468w==" + }, "node_modules/@neovici/cosmoz-router": { "version": "11.0.0", "resolved": "https://registry.npmjs.org/@neovici/cosmoz-router/-/cosmoz-router-11.0.0.tgz", diff --git a/package.json b/package.json index ecb8e6b..60ec4f6 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "./next/*": "./src/next/*" }, "dependencies": { + "@neovici/cosmoz-collapse": "^1.3.0", "@neovici/cosmoz-router": "^11.0.0", "@neovici/cosmoz-utils": "^6.0.0", "@pionjs/pion": "^2.0.0", diff --git a/src/cosmoz-tab-card.js b/src/cosmoz-tab-card.js index 7da5af0..39343a7 100644 --- a/src/cosmoz-tab-card.js +++ b/src/cosmoz-tab-card.js @@ -1,5 +1,18 @@ // @license Copyright (C) 2015 Neovici AB - Apache 2 License -import { html, component } from '@pionjs/pion'; +import { html, component, useState, useEffect } from '@pionjs/pion'; +import '@neovici/cosmoz-collapse'; +import { when } from 'lit-html/directives/when.js'; +import { css } from './utils'; + +const collapseIcon = html` + +`; /** @@ -19,60 +32,95 @@ Custom property | Description | Default `--cosmoz-tab-card-content-line-height` | Card content line height | `initial` `--cosmoz-tab-card-content-padding` | Card content padding | `initial` */ -const CosmozTabCard = ({ heading }) => - html` - -