Skip to content

Commit

Permalink
fix: icon for collapse and logic tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloBar1 committed Jan 31, 2024
1 parent 8237e21 commit a2248a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"eslint.validate": [ "javascript" ],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
}
20 changes: 8 additions & 12 deletions src/cosmoz-tab-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Custom property | Description | Default
`--cosmoz-tab-card-content-padding` | Card content padding | `initial`
*/

const CosmozTabCard = ({ heading, collapsable }) => {
const [collapsed, setCollapsed] = useState(false);
const CosmozTabCard = ({ heading, collapsable, collapsed }) => {
const [isCollapsed, setCollapsed] = useState(collapsed);
return html` <style>
:host {
display: block;
Expand Down Expand Up @@ -65,10 +65,10 @@ const CosmozTabCard = ({ heading, collapsable }) => {
<div id="header" part="header">
${collapsable
? html`<input
type="checkbox"
@change=${() => setCollapsed((c) => !c)}
/>`
? html`<iron-icon
icon="icons:info"
@click=${() => setCollapsed((c) => !c)}
></iron-icon>`
: nothing}
<h1 class="heading" part="heading">
${heading}<slot name="after-title"></slot>
Expand All @@ -77,16 +77,12 @@ const CosmozTabCard = ({ heading, collapsable }) => {
</div>
<div id="content" part="content">
${collapsable
? html`<cosmoz-collapse ?opened=${collapsed}
><slot></slot
></cosmoz-collapse>`
: html`<slot></slot>`}
<cosmoz-collapse ?opened=${!isCollapsed}><slot></slot></cosmoz-collapse>
</div>`;
};
customElements.define(
'cosmoz-tab-card',
component(CosmozTabCard, {
observedAttributes: ['heading', 'collapsable'],
observedAttributes: ['heading', 'collapsable', 'collapsed'],
})
);
2 changes: 1 addition & 1 deletion stories/cosmoz-tab-card.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const basics = () => html`
</cosmoz-tab-card>
</cosmoz-tab>
<cosmoz-tab heading="Tab2" name="tab2">
<cosmoz-tab-card collapsable heading="Card2 - Collapsable!">
<cosmoz-tab-card collapsable collapsed="false" heading="Card2 - Collapsable!">
<p>
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce non libero eget lorem interdum lacinia.
Vivamus eu libero lacus. Vestibulum blandit ornare orci non imperdiet. Aliquam condimentum lacus mauris, id aliquet lectus faucibus vel.
Expand Down

0 comments on commit a2248a6

Please sign in to comment.