From bb781c3d208f520aba835e080c2c60ceee5f09df Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Fri, 20 Mar 2020 14:53:04 +0000 Subject: [PATCH] Completed Material Card Component --- .../materialdesign-components/components.json | 46 +++++++++++++++++++ .../src/Card/Card.svelte | 8 +++- .../src/Card/CardBody.svelte | 4 +- .../src/Card/CardHeader.svelte | 1 - .../src/Test/props.js | 17 +++---- 5 files changed, 59 insertions(+), 17 deletions(-) diff --git a/packages/materialdesign-components/components.json b/packages/materialdesign-components/components.json index d017e54b11..9289f77652 100644 --- a/packages/materialdesign-components/components.json +++ b/packages/materialdesign-components/components.json @@ -111,6 +111,52 @@ }, "tags": [] }, + "Card": { + "name": "Card", + "description": "A Material Card container. Accepts CardHeader, CardBody and CardFooter as possible children", + "props": { + "width": "string", + "height": "string", + "variant": { + "type": "options", + "options": ["standard", "outlined"], + "default": "standard" + } + } + }, + "CardBody": { + "name": "CardBody", + "description": "A Material CardBody component. Contains the main content of a Material Card component", + "props": { + "onClick": "event" + } + }, + "CardImage": { + "name": "CardImage", + "description": "An image component for the Material Card component", + "props": { + "displayHorizontal": "bool", + "url": "string", + "title": "string", + "subtitle": "string" + } + }, + "CardHeader": { + "name": "CardHeader", + "description": "Displays a icon, title and subtitle above main body of the Material Card component", + "props": { + "title": "string", + "subtitle": "string", + "icon": "string" + } + }, + "CardFooter": { + "name": "CardFooter", + "description": "Displays buttons / icon buttons as actions for the Material Card component", + "props": { + "padding": "string" + } + }, "Checkbox": { "name": "Checkbox", "description": "A Material Design checkbox. Supports aligning label before or after checkbox.", diff --git a/packages/materialdesign-components/src/Card/Card.svelte b/packages/materialdesign-components/src/Card/Card.svelte index d32f34f04f..6a67ceb92c 100644 --- a/packages/materialdesign-components/src/Card/Card.svelte +++ b/packages/materialdesign-components/src/Card/Card.svelte @@ -21,18 +21,22 @@ $: props = { modifiers } $: cardClass = cb.build({ props }) + $: safeWidth = width !== "auto" && !/px$/.test(width) ? `${width}px` : width + $: safeHeight = + height !== "auto" && !/px$/.test(height) ? `${width}px` : height + $: card && _bb.attachChildren(card)