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/src/DatePicker/DatePicker.svelte b/packages/materialdesign-components/src/DatePicker/DatePicker.svelte
index 142805533f..d43cbc072e 100644
--- a/packages/materialdesign-components/src/DatePicker/DatePicker.svelte
+++ b/packages/materialdesign-components/src/DatePicker/DatePicker.svelte
@@ -17,21 +17,22 @@
import { Body1, Body2, Caption } from "../Typography"
import { IconButton } from "../IconButton"
- let textFieldHeight = null
let menu
let instance
+ let textfieldValue = ""
let daysArr = []
let navDate = new Date()
const weekdayMap = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
export let date = new Date()
- export let open = true
+ export let label = ""
+ export let onSelect = selectedDate => {}
onMount(() => {
if (!!menu) {
instance = new MDCMenu(menu)
- instance.open = true
+ instance.open = false
instance.setFixedPostion = true
}
})
@@ -40,6 +41,7 @@
let month = getMonth(navDate)
let year = getYear(navDate)
date = new Date(year, month, dayOfMonth)
+ onSelect(date)
}
function addMonth() {
@@ -50,8 +52,21 @@
navDate = subMonths(navDate, 1)
}
- function openCalendar() {
- instance.open = true
+ function openCalendar(isOpen) {
+ instance.open = isOpen === undefined ? !instance.open : isOpen
+ }
+
+ function textFieldChange(value) {
+ const isDate = /^\d{1,2}\/\d{1,2}\/\d{4}$/
+ if (isDate.test(value)) {
+ const [year, month, day] = value.split("/").reverse()
+ if (month > 0 && month <= 12 && (day > 0 && day <= 31)) {
+ date = new Date(year, month - 1, day)
+ navDate = date
+ openCalendar(true)
+ onSelect(date)
+ }
+ }
}
$: dateMonthEnds = endOfMonth(navDate).getDate()
@@ -71,23 +86,17 @@
dateMonthBegins > 5 && daysArr[daysArr.length - 1] > 30 ? 6 : 5
$: sameMonthAndYear =
getMonth(date) === getMonth(navDate) && getYear(date) === getYear(navDate)
- $: console.log(textFieldHeight)
-
+
@@ -157,10 +162,6 @@
grid-gap: 5px;
}
- .calendar-container > div {
- /* border: 1px solid red; */
- }
-
.week-days {
display: grid;
grid-template-columns: repeat(7, 1fr);
@@ -174,8 +175,4 @@
.centreText {
text-align: center;
}
-
- span {
- margin: auto;
- }
diff --git a/packages/materialdesign-components/src/DatePicker/_style.scss b/packages/materialdesign-components/src/DatePicker/_style.scss
index 8257eb7409..6cc1f5510a 100644
--- a/packages/materialdesign-components/src/DatePicker/_style.scss
+++ b/packages/materialdesign-components/src/DatePicker/_style.scss
@@ -2,7 +2,7 @@
@import "@material/theme/mixins";
.bbmd-day {
- transition: background-color 0.5s ease-in;
+ transition: background-color .25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
display: flex;
border-radius: 50%;
justify-content: center;
diff --git a/packages/materialdesign-components/src/IconButton/IconButton.svelte b/packages/materialdesign-components/src/IconButton/IconButton.svelte
index 13a2c899f0..57580776e3 100644
--- a/packages/materialdesign-components/src/IconButton/IconButton.svelte
+++ b/packages/materialdesign-components/src/IconButton/IconButton.svelte
@@ -4,6 +4,8 @@
const cb = new ClassBuilder("icon-button")
+ let on = false
+
export let _bb
export let context = ""
export let onClick = () => {}
@@ -13,6 +15,11 @@
export let onIcon = "" //on state icon for toggle button
export let size = "medium"
+ function onButtonClick() {
+ open = !open
+ onClick()
+ }
+
$: isToggleButton = !!icon && !!onIcon
$: useLinkButton = !!href
@@ -22,20 +29,10 @@
{#if useLinkButton}
-
- {#if isToggleButton}
-
- {onIcon}
-
- {icon}
- {:else}{icon}{/if}
-
-{:else}
-