Completed Material Card Component
This commit is contained in:
parent
bdd84d21b2
commit
bb781c3d20
|
@ -111,6 +111,52 @@
|
||||||
},
|
},
|
||||||
"tags": []
|
"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": {
|
"Checkbox": {
|
||||||
"name": "Checkbox",
|
"name": "Checkbox",
|
||||||
"description": "A Material Design checkbox. Supports aligning label before or after checkbox.",
|
"description": "A Material Design checkbox. Supports aligning label before or after checkbox.",
|
||||||
|
|
|
@ -21,12 +21,16 @@
|
||||||
$: props = { modifiers }
|
$: props = { modifiers }
|
||||||
$: cardClass = cb.build({ props })
|
$: 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)
|
$: card && _bb.attachChildren(card)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
bind:this={card}
|
bind:this={card}
|
||||||
style={`width: ${width}; height: ${height}`}
|
style={`width: ${safeWidth}; height: ${safeHeight}`}
|
||||||
class={cardClass} />
|
class={cardClass} />
|
||||||
|
|
||||||
<!-- <CardHeader title="Eyeoo" subtitle="efe wfew rregreg" />
|
<!-- <CardHeader title="Eyeoo" subtitle="efe wfew rregreg" />
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
export let _bb
|
export let _bb
|
||||||
export let isPrimaryAction = false
|
|
||||||
export let onClick = () => {}
|
export let onClick = () => {}
|
||||||
|
|
||||||
let cardBody
|
let cardBody
|
||||||
let cls = isPrimaryAction ? "mdc-card__primary-action" : ""
|
|
||||||
|
|
||||||
$: cardBody && _bb.attachChildren(cardBody)
|
$: cardBody && _bb.attachChildren(cardBody)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={cardBody} class={cls} on:click={onClick} />
|
<div bind:this={cardBody} class="mdc-card__primary-action" on:click={onClick} />
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
export let icon = ""
|
export let icon = ""
|
||||||
|
|
||||||
$: useIcon = !!icon
|
$: useIcon = !!icon
|
||||||
|
|
||||||
$: useSubtitle = !!subtitle
|
$: useSubtitle = !!subtitle
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -218,29 +218,24 @@ export const props = {
|
||||||
icon: "calendar_today",
|
icon: "calendar_today",
|
||||||
},
|
},
|
||||||
Card: {
|
Card: {
|
||||||
|
_id: "card",
|
||||||
|
width: "400",
|
||||||
_component: "@budibase/materialdesign-components/Card",
|
_component: "@budibase/materialdesign-components/Card",
|
||||||
_children: [
|
_children: [
|
||||||
{
|
{
|
||||||
|
_id: "cardbody",
|
||||||
_component: "@budibase/materialdesign-components/CardBody",
|
_component: "@budibase/materialdesign-components/CardBody",
|
||||||
|
onClick: () => alert`Hi`,
|
||||||
_children: [
|
_children: [
|
||||||
{
|
{
|
||||||
|
_id: "cardimage1",
|
||||||
_component: "@budibase/materialdesign-components/CardImage",
|
_component: "@budibase/materialdesign-components/CardImage",
|
||||||
_children: [],
|
_children: [],
|
||||||
displayHorizontal: false,
|
displayHorizontal: true,
|
||||||
url: "https://picsum.photos/350",
|
url: "https://picsum.photos/350",
|
||||||
title: "Our New World",
|
title: "Our New World",
|
||||||
subtitle: "Out now in cinemas",
|
subtitle: "Out now in cinemas",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
_component: "@budibase/materialdesign-components/H6",
|
|
||||||
_children: [],
|
|
||||||
text: "Movie Of The Year",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
_component: "@budibase/materialdesign-components/Body2",
|
|
||||||
_children: [],
|
|
||||||
text: "The most epic movie of the year has just arrived in cinemas",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue