From 31eb063cf6318c6825300c10ba8c53658e289452 Mon Sep 17 00:00:00 2001 From: Conor Mack Date: Sat, 7 Mar 2020 16:33:44 +0000 Subject: [PATCH 1/9] WIP: Poc for date picker --- .../src/DatePicker/DatePicker.svelte | 10 ++++++++++ .../materialdesign-components/src/DatePicker/index.js | 1 + .../materialdesign-components/src/Menu/Menu.svelte | 1 + .../materialdesign-components/src/Test/TestApp.svelte | 2 ++ packages/materialdesign-components/src/Test/props.js | 6 +++++- packages/materialdesign-components/src/index.js | 1 + 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 packages/materialdesign-components/src/DatePicker/DatePicker.svelte create mode 100644 packages/materialdesign-components/src/DatePicker/index.js diff --git a/packages/materialdesign-components/src/DatePicker/DatePicker.svelte b/packages/materialdesign-components/src/DatePicker/DatePicker.svelte new file mode 100644 index 0000000000..946bcd9dd7 --- /dev/null +++ b/packages/materialdesign-components/src/DatePicker/DatePicker.svelte @@ -0,0 +1,10 @@ + + + + diff --git a/packages/materialdesign-components/src/DatePicker/index.js b/packages/materialdesign-components/src/DatePicker/index.js new file mode 100644 index 0000000000..76af457b24 --- /dev/null +++ b/packages/materialdesign-components/src/DatePicker/index.js @@ -0,0 +1 @@ +export { default as DatePicker } from "./DatePicker.svelte" diff --git a/packages/materialdesign-components/src/Menu/Menu.svelte b/packages/materialdesign-components/src/Menu/Menu.svelte index 8439128208..7d2c40c3d0 100644 --- a/packages/materialdesign-components/src/Menu/Menu.svelte +++ b/packages/materialdesign-components/src/Menu/Menu.svelte @@ -39,6 +39,7 @@ }) $: menuList && _bb.attachChildren(menuList) + debugger {#if useFixedPosition || useAbsolutePosition} diff --git a/packages/materialdesign-components/src/Test/TestApp.svelte b/packages/materialdesign-components/src/Test/TestApp.svelte index baf3db4c81..f011be3089 100644 --- a/packages/materialdesign-components/src/Test/TestApp.svelte +++ b/packages/materialdesign-components/src/Test/TestApp.svelte @@ -17,6 +17,7 @@ Icon, List, Select, + DatePicker, } = props let currentComponent @@ -28,6 +29,7 @@ props: { _component: "testcomponents/rootComponent", _children: [ + DatePicker, Button, BodyBoundToStore, Textfield, diff --git a/packages/materialdesign-components/src/Test/props.js b/packages/materialdesign-components/src/Test/props.js index 73672f7b3e..e1f148c963 100644 --- a/packages/materialdesign-components/src/Test/props.js +++ b/packages/materialdesign-components/src/Test/props.js @@ -205,5 +205,9 @@ export const props = { value: "2", }, ], - } + }, + DatePicker: { + _component: "@budibase/materialdesign-components/ListItem", + _children: [], + }, } diff --git a/packages/materialdesign-components/src/index.js b/packages/materialdesign-components/src/index.js index 5e1df0081e..7575f19786 100644 --- a/packages/materialdesign-components/src/index.js +++ b/packages/materialdesign-components/src/index.js @@ -19,3 +19,4 @@ export { default as recordForm } from "./Templates/recordForm" export { List, ListItem } from "./List" export { Menu } from "./Menu" export { Select } from "./Select" +export { DatePicker } from "./DatePicker" From 7c23e644e065595807faef711bf60c081e5da89f Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Wed, 11 Mar 2020 14:04:47 +0000 Subject: [PATCH 2/9] 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}