From 082997585b51245c8d151d864e3f5d2ce5921c02 Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Wed, 11 Mar 2020 14:04:47 +0000 Subject: [PATCH] Datepicker and Icon Button --- package.json | 5 +- .../src/Common/Icon.svelte | 21 ++ .../src/Common/Ripple.js | 2 +- .../src/DatePicker/DatePicker.svelte | 187 +++++++++++++++++- .../src/DatePicker/_style.scss | 15 ++ .../src/DatePicker/index.js | 3 +- .../src/IconButton/IconButton.svelte | 40 ++++ .../src/IconButton/_style.scss | 13 ++ .../src/IconButton/index.js | 2 + .../src/Menu/Menu.svelte | 1 - .../src/Textfield/Textfield.svelte | 3 +- .../src/Typography/Caption.svelte | 2 +- .../materialdesign-components/src/index.js | 1 + yarn.lock | 61 ++++++ 14 files changed, 344 insertions(+), 12 deletions(-) create mode 100644 packages/materialdesign-components/src/DatePicker/_style.scss create mode 100644 packages/materialdesign-components/src/IconButton/IconButton.svelte create mode 100644 packages/materialdesign-components/src/IconButton/_style.scss create mode 100644 packages/materialdesign-components/src/IconButton/index.js diff --git a/package.json b/package.json index 01e91b64ac..ea235ae5b4 100644 --- a/package.json +++ b/package.json @@ -24,5 +24,8 @@ "lint:fix": "eslint --fix packages", "format": "prettier --write \"{,!(node_modules)/**/}*.{js,jsx,svelte}\"" }, - "dependencies": {} + "dependencies": { + "@material/icon-button": "4.0.0", + "date-fns": "^2.10.0" + } } diff --git a/packages/materialdesign-components/src/Common/Icon.svelte b/packages/materialdesign-components/src/Common/Icon.svelte index d4820fcf6c..bb2ac8d957 100644 --- a/packages/materialdesign-components/src/Common/Icon.svelte +++ b/packages/materialdesign-components/src/Common/Icon.svelte @@ -1,10 +1,31 @@ {icon} +{#if useRipple} +
+ {icon} +
+{:else} + {icon} +{/if} + + diff --git a/packages/materialdesign-components/src/Common/Ripple.js b/packages/materialdesign-components/src/Common/Ripple.js index 2553bbca65..6a19dac3ea 100644 --- a/packages/materialdesign-components/src/Common/Ripple.js +++ b/packages/materialdesign-components/src/Common/Ripple.js @@ -2,7 +2,7 @@ import { MDCRipple } from "@material/ripple" export default function ripple( node, - props = { colour: "primary", unbounded: false } + props = { colour: "primary", unbounded: true } ) { node.classList.add("mdc-ripple-surface") let component = new MDCRipple(node) diff --git a/packages/materialdesign-components/src/DatePicker/DatePicker.svelte b/packages/materialdesign-components/src/DatePicker/DatePicker.svelte index 946bcd9dd7..e5b693de6e 100644 --- a/packages/materialdesign-components/src/DatePicker/DatePicker.svelte +++ b/packages/materialdesign-components/src/DatePicker/DatePicker.svelte @@ -1,10 +1,185 @@ - - + + + +
+ + +
+
+
+ + + +
+ +
+ + + +
+
+ {#each weekdayMap as day, i} +
+ +
+ {/each} +
+
+ {#each daysArr as day, i} +
selectDate(day)} + class={`bbmd-day ${dayOfSelectedDate === day && sameMonthAndYear ? 'selected' : ''}`}> + {#if i === 0} +
+ +
+ {:else} + + {/if} +
+ {/each} +
+
+ +
+
diff --git a/packages/materialdesign-components/src/DatePicker/_style.scss b/packages/materialdesign-components/src/DatePicker/_style.scss new file mode 100644 index 0000000000..8257eb7409 --- /dev/null +++ b/packages/materialdesign-components/src/DatePicker/_style.scss @@ -0,0 +1,15 @@ +@import "@material/ripple/mdc-ripple.scss"; +@import "@material/theme/mixins"; + +.bbmd-day { + transition: background-color 0.5s ease-in; + display: flex; + border-radius: 50%; + justify-content: center; + align-items: center; + cursor: pointer; +} +.selected { + @include mdc-theme-prop(background-color, primary); + @include mdc-theme-prop(color, on-primary); +} diff --git a/packages/materialdesign-components/src/DatePicker/index.js b/packages/materialdesign-components/src/DatePicker/index.js index 76af457b24..de6a6e1f09 100644 --- a/packages/materialdesign-components/src/DatePicker/index.js +++ b/packages/materialdesign-components/src/DatePicker/index.js @@ -1 +1,2 @@ -export { default as DatePicker } from "./DatePicker.svelte" +import "./_style.scss"; +export { default as DatePicker } from "./DatePicker.svelte"; diff --git a/packages/materialdesign-components/src/IconButton/IconButton.svelte b/packages/materialdesign-components/src/IconButton/IconButton.svelte new file mode 100644 index 0000000000..bbadade28e --- /dev/null +++ b/packages/materialdesign-components/src/IconButton/IconButton.svelte @@ -0,0 +1,40 @@ + + +{#if useLinkButton} + + {#if isToggleButton} + + {onIcon} + + {icon} + {:else}{icon}{/if} + +{:else} + +{/if} diff --git a/packages/materialdesign-components/src/IconButton/_style.scss b/packages/materialdesign-components/src/IconButton/_style.scss new file mode 100644 index 0000000000..587374638f --- /dev/null +++ b/packages/materialdesign-components/src/IconButton/_style.scss @@ -0,0 +1,13 @@ +@import "@material/icon-button/mdc-icon-button"; + +.bbmd-mdc-icon-button--size-large { + @include mdc-icon-button-icon-size(24px); +} + +.bbmd-mdc-icon-button--size-medium { + @include mdc-icon-button-icon-size(20px); +} + +.bbmd-mdc-icon-button--size-small { + @include mdc-icon-button-icon-size(16px); +} diff --git a/packages/materialdesign-components/src/IconButton/index.js b/packages/materialdesign-components/src/IconButton/index.js new file mode 100644 index 0000000000..697e69f10c --- /dev/null +++ b/packages/materialdesign-components/src/IconButton/index.js @@ -0,0 +1,2 @@ +import "./_style.scss"; +export { default as IconButton } from "./IconButton.svelte"; diff --git a/packages/materialdesign-components/src/Menu/Menu.svelte b/packages/materialdesign-components/src/Menu/Menu.svelte index 7d2c40c3d0..8439128208 100644 --- a/packages/materialdesign-components/src/Menu/Menu.svelte +++ b/packages/materialdesign-components/src/Menu/Menu.svelte @@ -39,7 +39,6 @@ }) $: menuList && _bb.attachChildren(menuList) - debugger {#if useFixedPosition || useAbsolutePosition} diff --git a/packages/materialdesign-components/src/Textfield/Textfield.svelte b/packages/materialdesign-components/src/Textfield/Textfield.svelte index 7de3141e54..7285876317 100644 --- a/packages/materialdesign-components/src/Textfield/Textfield.svelte +++ b/packages/materialdesign-components/src/Textfield/Textfield.svelte @@ -13,6 +13,7 @@ const cb = new ClassBuilder("text-field", ["primary", "medium"]) let tf = null + export let tfHeight = null let tfInstance = null onMount(() => { @@ -105,7 +106,7 @@ TODO:Needs error handling - this will depend on how Budibase handles errors -->
-
+
{#if textarea}