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/components.json b/packages/materialdesign-components/components.json index 0028b39545..d017e54b11 100644 --- a/packages/materialdesign-components/components.json +++ b/packages/materialdesign-components/components.json @@ -169,6 +169,16 @@ "description": "Material Design .", "props": {} }, + "DatePicker": { + "name": "DatePicker", + "description": "Material Design DatePicker", + "props": { + "date": "string", + "label": "string", + "onSelect": "event" + }, + "tags": [] + }, "H1": { "name": "H1", "description": "Sets the font properties as Roboto Headline1", @@ -217,6 +227,18 @@ }, "tags": [] }, + "IconButton": { + "onClick": "event", + "disabled": "bool", + "href": "string", + "icon": "string", + "size": { + "type":"options", + "options": ["small", "medium", "large"], + "default": "medium" + }, + "tags": [] + }, "Label": { "name": "Label", "description": "A simple label component that displays its text in the standard Roboto Material Design font", diff --git a/packages/materialdesign-components/package.json b/packages/materialdesign-components/package.json index 576aebeed5..f21c6c8d6b 100644 --- a/packages/materialdesign-components/package.json +++ b/packages/materialdesign-components/package.json @@ -18,6 +18,7 @@ "@material/checkbox": "^4.0.0", "@material/data-table": "4.0.0", "@material/form-field": "^4.0.0", + "@material/icon-button": "4.0.0", "@material/list": "4.0.0", "@material/menu": "4.0.0", "@material/radio": "^4.0.0", @@ -25,6 +26,7 @@ "@material/textfield": "^4.0.0", "@nx-js/compiler-util": "^2.0.0", "bcryptjs": "^2.4.3", + "date-fns": "^2.10.0", "fs-extra": "^8.1.0", "lodash": "^4.17.15", "npm-run-all": "^4.1.5", 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 new file mode 100644 index 0000000000..d43cbc072e --- /dev/null +++ b/packages/materialdesign-components/src/DatePicker/DatePicker.svelte @@ -0,0 +1,178 @@ + + +
+ + +
+
+
+
+ +
+
+ +
+
+ +
+
+
+ {#each weekdayMap as day, i} +
+ +
+ {/each} +
+
+ {#each daysArr as day, i} +
selectDate(day)} + class={`bbmd-day ${dayOfSelectedDate === day && sameMonthAndYear ? 'selected' : ''}`}> + +
+ {/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..6cc1f5510a --- /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 .25s cubic-bezier(0.25, 0.46, 0.45, 0.94); + 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 new file mode 100644 index 0000000000..de6a6e1f09 --- /dev/null +++ b/packages/materialdesign-components/src/DatePicker/index.js @@ -0,0 +1,2 @@ +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..57580776e3 --- /dev/null +++ b/packages/materialdesign-components/src/IconButton/IconButton.svelte @@ -0,0 +1,66 @@ + + +{#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..412ea0ad6a --- /dev/null +++ b/packages/materialdesign-components/src/IconButton/_style.scss @@ -0,0 +1,18 @@ +@import "@material/icon-button/mdc-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/Test/TestApp.svelte b/packages/materialdesign-components/src/Test/TestApp.svelte index baf3db4c81..a84d0280d4 100644 --- a/packages/materialdesign-components/src/Test/TestApp.svelte +++ b/packages/materialdesign-components/src/Test/TestApp.svelte @@ -17,6 +17,8 @@ Icon, List, Select, + DatePicker, + IconButton, } = props let currentComponent @@ -34,6 +36,8 @@ Select, Radiobutton, Radiobuttongroup, + DatePicker, + IconButton, ], }, } diff --git a/packages/materialdesign-components/src/Test/props.js b/packages/materialdesign-components/src/Test/props.js index 73672f7b3e..e53441c8ce 100644 --- a/packages/materialdesign-components/src/Test/props.js +++ b/packages/materialdesign-components/src/Test/props.js @@ -205,5 +205,16 @@ export const props = { value: "2", }, ], - } + }, + DatePicker: { + _component: "@budibase/materialdesign-components/DatePicker", + _children: [], + label: "Date of Admission", + onSelect: date => console.log("SELECTED DATE", date) + }, + IconButton: { + _component: "@budibase/materialdesign-components/IconButton", + _children: [], + icon: "calendar_today", + }, } diff --git a/packages/materialdesign-components/src/Textfield/Textfield.svelte b/packages/materialdesign-components/src/Textfield/Textfield.svelte index 7de3141e54..36c4618df3 100644 --- a/packages/materialdesign-components/src/Textfield/Textfield.svelte +++ b/packages/materialdesign-components/src/Textfield/Textfield.svelte @@ -9,10 +9,12 @@ import HelperText from "./HelperText.svelte" import CharacterCounter from "./CharacterCounter.svelte" import Icon from "../Common/Icon.svelte" + import { IconButton } from "../IconButton" const cb = new ClassBuilder("text-field", ["primary", "medium"]) let tf = null + export let tfHeight = null let tfInstance = null onMount(() => { @@ -40,6 +42,8 @@ export let placeholder = "" export let icon = "" export let trailingIcon = false + export let useIconButton = false + export let iconButtonClick = () => {} export let textarea = false export let rows = 4 export let cols = 40 @@ -93,10 +97,11 @@ function changed(e) { const val = e.target.value value = val - if (_bb.isBound(_bb.props.value)) { - _bb.setStateFromBinding(_bb.props.value, val) - } - _bb.call(onChange, val) + onChange(value) + // if (_bb.isBound(_bb.props.value)) { + // _bb.setStateFromBinding(_bb.props.value, val) + // } + // _bb.call(onChange, val) } @@ -105,7 +110,7 @@ TODO:Needs error handling - this will depend on how Budibase handles errors -->
-
+
{#if textarea}