Card with lay undefined issue
This commit is contained in:
parent
88f1129688
commit
bdd84d21b2
|
@ -50,5 +50,7 @@
|
|||
"version": "0.0.27",
|
||||
"license": "MIT",
|
||||
"gitHead": "72a77a035eb7c1443b079bf93c29b3e5fe02094e",
|
||||
"dependencies": {}
|
||||
"dependencies": {
|
||||
"@material/card": "4.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { setContext, getContext } from "svelte"
|
||||
import { onMount } from "svelte"
|
||||
import Icon from "../Common/Icon.svelte"
|
||||
import ripple from "../Common/Ripple.js"
|
||||
import ClassBuilder from "../ClassBuilder.js"
|
||||
|
@ -22,12 +22,18 @@
|
|||
|
||||
export let _bb
|
||||
|
||||
onMount(() => {
|
||||
let ctx = _bb.getContext("BBMD:button:context")
|
||||
extras = [ctx]
|
||||
})
|
||||
|
||||
let extras = ""
|
||||
let modifiers = {}
|
||||
let customs = { size, colour }
|
||||
|
||||
if (!href) modifiers = { variant }
|
||||
|
||||
let props = { modifiers, customs }
|
||||
let props = { modifiers, customs, extras }
|
||||
|
||||
let blockClasses = cb.build({ props })
|
||||
const labelClass = cb.elem("label")
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<script>
|
||||
import CardHeader from "./CardHeader.svelte"
|
||||
import CardBody from "./CardBody.svelte"
|
||||
import CardImage from "./CardImage.svelte"
|
||||
import CardFooter from "./CardFooter.svelte"
|
||||
import { H2, H6, Body2 } from "../Typography"
|
||||
import { Button } from "../Button"
|
||||
import { IconButton } from "../IconButton"
|
||||
import ClassBuilder from "../ClassBuilder.js"
|
||||
|
||||
export let width = "350px"
|
||||
export let height = "auto"
|
||||
export let variant = "standard"
|
||||
|
||||
export let _bb
|
||||
let card
|
||||
|
||||
const cb = new ClassBuilder("card", ["standard"])
|
||||
|
||||
$: modifiers = { variant }
|
||||
$: props = { modifiers }
|
||||
$: cardClass = cb.build({ props })
|
||||
|
||||
$: card && _bb.attachChildren(card)
|
||||
</script>
|
||||
|
||||
<div
|
||||
bind:this={card}
|
||||
style={`width: ${width}; height: ${height}`}
|
||||
class={cardClass} />
|
||||
|
||||
<!-- <CardHeader title="Eyeoo" subtitle="efe wfew rregreg" />
|
||||
<CardBody isPrimaryAction>
|
||||
<CardImage url="https://picsum.photos/350/200" />
|
||||
<H6 text="Body Header" horizontalMargin={10} />
|
||||
<Body2 text="something something mc something" horizontalMargin={10} />
|
||||
</CardBody>
|
||||
<CardFooter>
|
||||
<Button {_bb} text="Save" />
|
||||
<Button {_bb} text="Cancel" />
|
||||
<IconButton icon="3d_rotation" />
|
||||
<IconButton icon="accessibility" />
|
||||
<IconButton icon="alarm" />
|
||||
|
||||
</CardFooter> -->
|
|
@ -0,0 +1,12 @@
|
|||
<script>
|
||||
export let _bb
|
||||
export let isPrimaryAction = false
|
||||
export let onClick = () => {}
|
||||
|
||||
let cardBody
|
||||
let cls = isPrimaryAction ? "mdc-card__primary-action" : ""
|
||||
|
||||
$: cardBody && _bb.attachChildren(cardBody)
|
||||
</script>
|
||||
|
||||
<div bind:this={cardBody} class={cls} on:click={onClick} />
|
|
@ -0,0 +1,31 @@
|
|||
<script>
|
||||
import { onMount } from "svelte"
|
||||
let cardFooter
|
||||
export let _bb
|
||||
export let padding = "5px"
|
||||
|
||||
onMount(() => {
|
||||
_bb.setContext(
|
||||
"BBMD:icon-button:context",
|
||||
"mdc-card__action mdc-card__action--icon"
|
||||
)
|
||||
_bb.setContext(
|
||||
"BBMD:button:context",
|
||||
"mdc-card__action mdc-card__action--button"
|
||||
)
|
||||
})
|
||||
|
||||
$: cardFooter && _bb.attachChildren(cardFooter)
|
||||
</script>
|
||||
|
||||
<div
|
||||
bind:this={cardFooter}
|
||||
style={`padding: ${padding}`}
|
||||
class="mdc-card__actions bbmd-card__actions" />
|
||||
|
||||
<style>
|
||||
.bbmd-card__actions {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,45 @@
|
|||
<script>
|
||||
import { H6, Sub2 } from "../Typography"
|
||||
import Icon from "../Common/Icon.svelte"
|
||||
export let _bb
|
||||
export let title = ""
|
||||
export let subtitle = ""
|
||||
export let icon = ""
|
||||
|
||||
$: useIcon = !!icon
|
||||
|
||||
$: useSubtitle = !!subtitle
|
||||
</script>
|
||||
|
||||
<div class="card-header">
|
||||
{#if useIcon}
|
||||
<div class="card-header__icon">
|
||||
<Icon {icon} />
|
||||
</div>
|
||||
{/if}
|
||||
<div class="card-header__title">
|
||||
<H6 text={title} />
|
||||
{#if useSubtitle}
|
||||
<Sub2 text={subtitle} />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.card-header {
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.card-header__icon {
|
||||
flex: 0;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.card-header__title {
|
||||
display: flex;
|
||||
flex-flow: column nowrap;
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,62 @@
|
|||
<script>
|
||||
import { H6, Sub2 } from "../Typography"
|
||||
export let _bb
|
||||
export let displayHorizontal = false //aligns image on row with title and subtitle text
|
||||
export let url = ""
|
||||
export let title = ""
|
||||
export let subtitle = ""
|
||||
|
||||
$: useTitle = !!title
|
||||
$: useSubTitle = !!subtitle
|
||||
</script>
|
||||
|
||||
{#if !displayHorizontal}
|
||||
<div
|
||||
class="my-card__media mdc-card__media mdc-card__media--16-9"
|
||||
style={`background-image: url(${url})`}>
|
||||
<div class="mdc-card__media-content bbmd-card-media__content">
|
||||
{#if useTitle}
|
||||
<H6 text={title} verticalMargin={0} horizontalMargin={10} />
|
||||
{#if useSubTitle}
|
||||
<Sub2 text={subtitle} horizontalMargin={10} />
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="bbmd-card--horizontal">
|
||||
<div
|
||||
class="mdc-card__media mdc-card__media mdc-card__media--square
|
||||
bbmd-card--horizontal-image"
|
||||
style={`background-image: url(${url})`} />
|
||||
<div class="bbmd-card--horizontal-text">
|
||||
{#if useTitle}
|
||||
<H6 text={title} verticalMargin={0} horizontalMargin={10} />
|
||||
{#if useSubTitle}
|
||||
<Sub2 text={subtitle} horizontalMargin={10} />
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.bbmd-card--horizontal {
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
}
|
||||
|
||||
.bbmd-card--horizontal-image {
|
||||
flex: 0 0 110px;
|
||||
}
|
||||
|
||||
.bbmd-card--horizontal-text {
|
||||
flex: 1;
|
||||
padding: 10px 5px;
|
||||
}
|
||||
|
||||
.bbmd-card-media__content {
|
||||
top: 125px;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1 @@
|
|||
@import "@material/card/mdc-card.scss"
|
|
@ -0,0 +1,7 @@
|
|||
import "./_styles.scss"
|
||||
export { default as Card } from "./Card.svelte"
|
||||
export { default as CardBody } from "./CardBody.svelte"
|
||||
export { default as CardFooter } from "./CardFooter.svelte"
|
||||
export { default as CardHeader } from "./CardHeader.svelte"
|
||||
export { default as CardImage } from "./CardImage.svelte"
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
<script>
|
||||
import { getContext } from "svelte"
|
||||
|
||||
export let icon = ""
|
||||
export let context = ""
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
let navDate = new Date()
|
||||
const weekdayMap = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
|
||||
|
||||
export let _bb
|
||||
export let date = new Date()
|
||||
export let label = ""
|
||||
export let onSelect = selectedDate => {}
|
||||
|
@ -105,13 +106,13 @@
|
|||
<div class="calendar-container">
|
||||
<div class="month-picker">
|
||||
<div>
|
||||
<IconButton icon="chevron_left" onClick={subtractMonth} />
|
||||
<IconButton icon="chevron_left" {_bb} onClick={subtractMonth} />
|
||||
</div>
|
||||
<div class="centreText">
|
||||
<Body1 text={monthAndYear} />
|
||||
</div>
|
||||
<div>
|
||||
<IconButton icon="chevron_right" onClick={addMonth} />
|
||||
<IconButton icon="chevron_right" {_bb} onClick={addMonth} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="week-days">
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<script>
|
||||
import { onMount } from "svelte"
|
||||
import ripple from "../Common/Ripple.js"
|
||||
import ClassBuilder from "../ClassBuilder.js"
|
||||
|
||||
|
@ -15,6 +16,14 @@
|
|||
export let onIcon = "" //on state icon for toggle button
|
||||
export let size = "medium"
|
||||
|
||||
onMount(() => {
|
||||
let ctx = !!_bb ? _bb.getContext("BBMD:icon-button:context") : ""
|
||||
//It isn't possible to use context within nested components as they do not have their own _bb instance (has to be passed down from parent component). This allows context to be passed as props
|
||||
if (!context && !!ctx) {
|
||||
context = ctx
|
||||
}
|
||||
})
|
||||
|
||||
function onButtonClick() {
|
||||
open = !open
|
||||
onClick()
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
Select,
|
||||
DatePicker,
|
||||
IconButton,
|
||||
Card,
|
||||
} = props
|
||||
|
||||
let currentComponent
|
||||
|
@ -38,6 +39,7 @@
|
|||
Radiobuttongroup,
|
||||
DatePicker,
|
||||
IconButton,
|
||||
Card,
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -210,11 +210,64 @@ export const props = {
|
|||
_component: "@budibase/materialdesign-components/DatePicker",
|
||||
_children: [],
|
||||
label: "Date of Admission",
|
||||
onSelect: date => console.log("SELECTED DATE", date)
|
||||
onSelect: date => console.log("SELECTED DATE", date),
|
||||
},
|
||||
IconButton: {
|
||||
_component: "@budibase/materialdesign-components/IconButton",
|
||||
_children: [],
|
||||
icon: "calendar_today",
|
||||
},
|
||||
Card: {
|
||||
_component: "@budibase/materialdesign-components/Card",
|
||||
_children: [
|
||||
{
|
||||
_component: "@budibase/materialdesign-components/CardBody",
|
||||
_children: [
|
||||
{
|
||||
_component: "@budibase/materialdesign-components/CardImage",
|
||||
_children: [],
|
||||
displayHorizontal: false,
|
||||
url: "https://picsum.photos/350",
|
||||
title: "Our New World",
|
||||
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",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
_component: "@budibase/materialdesign-components/CardFooter",
|
||||
_children: [
|
||||
{
|
||||
_component: "@budibase/materialdesign-components/Button",
|
||||
text: "Save",
|
||||
},
|
||||
{
|
||||
_component: "@budibase/materialdesign-components/Button",
|
||||
text: "Cancel",
|
||||
},
|
||||
{
|
||||
_component: "@budibase/materialdesign-components/IconButton",
|
||||
icon: "3d_rotation",
|
||||
},
|
||||
{
|
||||
_component: "@budibase/materialdesign-components/IconButton",
|
||||
icon: "accessibility",
|
||||
},
|
||||
{
|
||||
_component: "@budibase/materialdesign-components/IconButton",
|
||||
icon: "alarm_on",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<script>
|
||||
export let text = ""
|
||||
export let verticalMargin = 0
|
||||
export let horizontalMargin = 0
|
||||
</script>
|
||||
|
||||
<span class="mdc-typography--body2">{text}</span>
|
||||
<span
|
||||
style={`margin: ${verticalMargin}px ${horizontalMargin}px`}
|
||||
class="mdc-typography--body2">
|
||||
{text}
|
||||
</span>
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<script>
|
||||
export let text = ""
|
||||
export let verticalMargin = 5
|
||||
export let horizontalMargin = 0
|
||||
</script>
|
||||
|
||||
<h6 class="mdc-typography--headline6">{text}</h6>
|
||||
<h6
|
||||
style={`margin: ${verticalMargin}px ${horizontalMargin}px`}
|
||||
class="mdc-typography--headline6">
|
||||
{text}
|
||||
</h6>
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<script>
|
||||
export let text = ""
|
||||
export let verticalMargin = 5
|
||||
export let horizontalMargin = 0
|
||||
</script>
|
||||
|
||||
<span class="mdc-typography--subtitle2">{text}</span>
|
||||
<span
|
||||
style={`margin: ${verticalMargin}px ${horizontalMargin}px`}
|
||||
class="mdc-typography--subtitle2">
|
||||
{text}
|
||||
</span>
|
||||
|
|
|
@ -21,3 +21,10 @@ export { Menu } from "./Menu"
|
|||
export { Select } from "./Select"
|
||||
export { DatePicker } from "./DatePicker"
|
||||
export { IconButton } from "./IconButton"
|
||||
export { Card } from "./Card"
|
||||
export { CardHeader } from "./Card"
|
||||
export { CardImage } from "./Card"
|
||||
export { CardBody } from "./Card"
|
||||
export { CardFooter } from "./Card"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue