diff --git a/css/site.css b/css/site.css index 8d6a5a8..5d998cb 100644 --- a/css/site.css +++ b/css/site.css @@ -1 +1 @@ -/*! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.mx-auto{margin-left:auto;margin-right:auto}.\!mt-14{margin-top:3.5rem!important}.mb-8{margin-bottom:2rem}.mt-2{margin-top:.5rem}.flex{display:flex}.w-full{width:100%}.min-w-\[100px\]{min-width:100px}.max-w-3xl{max-width:48rem}.max-w-4xl{max-width:56rem}.max-w-\[12\%\]{max-width:12%}.scroll-py-4{scroll-padding-top:1rem;scroll-padding-bottom:1rem}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-y-5{row-gap:1.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.scroll-smooth{scroll-behavior:smooth}.rounded-3xl{border-radius:1.5rem}.border-t-2{border-top-width:2px}.border-solid{border-style:solid}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity))}.bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity))}.p-6{padding:1.5rem}.pb-10{padding-bottom:2.5rem}.pt-12{padding-top:3rem}.text-center{text-align:center}.font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-black{font-weight:900}.font-bold{font-weight:700}.leading-none{line-height:1}.tracking-tight{letter-spacing:-.025em}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity))}.text-zinc-800{--tw-text-opacity:1;color:rgb(39 39 42/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.decoration-2{text-decoration-thickness:2px}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}main p a{--tw-text-opacity:1;color:rgb(14 165 233/var(--tw-text-opacity));text-decoration-line:underline;text-decoration-thickness:2px;text-underline-offset:2px}main p a:focus,main p a:hover{text-decoration-line:none}fitness-card{--fitness-value:#a1a1aa}fitness-card::part(header){margin-bottom:2rem;border-width:0 0 2px;border-style:solid;--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity));padding-top:1.5rem;padding-bottom:1.5rem}@media (prefers-color-scheme:dark){fitness-card::part(header){--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity))}}fitness-card::part(footer){margin-top:2rem;border-width:2px 0 0;border-style:solid;--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity));padding-top:1.5rem;padding-bottom:1.5rem}@media (prefers-color-scheme:dark){fitness-card::part(footer){--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity))}}@media (min-width:640px){fitness-card::part(ring){max-width:250px}}.muted{--fitness-move:#f472b6;--fitness-exercise:#38bdf8;--fitness-stand:#2dd4bf}@media (prefers-color-scheme:dark){.muted{--fitness-move:#c026d3;--fitness-exercise:#2563eb;--fitness-stand:#059669}}.focus\:no-underline:focus,.hover\:no-underline:hover{text-decoration-line:none}.group:hover .group-hover\:underline{text-decoration-line:underline}@media (prefers-color-scheme:dark){.dark\:border-gray-700{--tw-border-opacity:1;border-color:rgb(55 65 81/var(--tw-border-opacity))}.dark\:bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity))}.dark\:text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity))}}@media (min-width:768px){.md\:mt-8{margin-top:2rem}.md\:text-2xl{font-size:1.5rem;line-height:2rem}.md\:text-8xl{font-size:6rem;line-height:1}.md\:text-lg{font-size:1.125rem;line-height:1.75rem}.md\:leading-\[0\.75\]{line-height:.75}} \ No newline at end of file +/*! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.mx-auto{margin-left:auto;margin-right:auto}.\!mt-14{margin-top:3.5rem!important}.mb-8{margin-bottom:2rem}.mt-2{margin-top:.5rem}.flex{display:flex}.w-full{width:100%}.min-w-\[100px\]{min-width:100px}.max-w-3xl{max-width:48rem}.max-w-4xl{max-width:56rem}.max-w-\[12\%\]{max-width:12%}.scroll-py-4{scroll-padding-top:1rem;scroll-padding-bottom:1rem}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-y-5{row-gap:1.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.scroll-smooth{scroll-behavior:smooth}.rounded-3xl{border-radius:1.5rem}.border-t-2{border-top-width:2px}.border-solid{border-style:solid}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity))}.bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity))}.p-6{padding:1.5rem}.pb-10{padding-bottom:2.5rem}.pt-12{padding-top:3rem}.text-center{text-align:center}.font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-black{font-weight:900}.font-bold{font-weight:700}.leading-none{line-height:1}.tracking-tight{letter-spacing:-.025em}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity))}.text-zinc-800{--tw-text-opacity:1;color:rgb(39 39 42/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.decoration-2{text-decoration-thickness:2px}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}main p a{--tw-text-opacity:1;color:rgb(14 165 233/var(--tw-text-opacity));text-decoration-line:underline;text-decoration-thickness:2px;text-underline-offset:2px}main p a:focus,main p a:hover{text-decoration-line:none}fitness-card{--fitness-value:#a1a1aa}fitness-card::part(header){margin-bottom:2rem;border-width:0 0 2px;border-style:solid;--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity));padding-top:1.5rem;padding-bottom:1.5rem}@media (prefers-color-scheme:dark){fitness-card::part(header){--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity))}}fitness-card::part(footer){margin-top:2rem;border-width:2px 0 0;border-style:solid;--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity));padding-top:1.5rem;padding-bottom:1.5rem}@media (prefers-color-scheme:dark){fitness-card::part(footer){--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity))}}@media (min-width:640px){fitness-card::part(ring){max-width:250px}}.muted{--fitness-calories:#f9a8d4;--fitness-minutes:#5eead4;--fitness-hours:#7dd3fc}@media (prefers-color-scheme:dark){.muted{--fitness-calories:#831843;--fitness-minutes:#134e4a;--fitness-hours:#0c4a6e}}.focus\:no-underline:focus,.hover\:no-underline:hover{text-decoration-line:none}.group:hover .group-hover\:underline{text-decoration-line:underline}@media (prefers-color-scheme:dark){.dark\:border-gray-700{--tw-border-opacity:1;border-color:rgb(55 65 81/var(--tw-border-opacity))}.dark\:bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity))}.dark\:text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity))}}@media (min-width:768px){.md\:mt-8{margin-top:2rem}.md\:text-2xl{font-size:1.5rem;line-height:2rem}.md\:text-8xl{font-size:6rem;line-height:1}.md\:text-lg{font-size:1.125rem;line-height:1.75rem}.md\:leading-\[0\.75\]{line-height:.75}} \ No newline at end of file diff --git a/index.html b/index.html index 776ab14..98cf284 100644 --- a/index.html +++ b/index.html @@ -43,9 +43,9 @@

25/09/2023 @@ -55,9 +55,9 @@

26/09/2023 @@ -67,9 +67,9 @@

27/09/2023 @@ -79,9 +79,9 @@

28/09/2023 @@ -91,9 +91,9 @@

29/09/2023 @@ -103,9 +103,9 @@

30/09/2023 @@ -115,9 +115,9 @@

01/10/2023 @@ -135,19 +135,22 @@

- +
Move
+
Exercise
+
Stand
+ - + - + @@ -160,19 +163,22 @@

- +
Move
+
Exercise
+
Stand
+ - + - + @@ -185,19 +191,22 @@

- +
Move
+
Exercise
+
Stand
+ - + - + @@ -210,19 +219,22 @@

- +
Move
+
Exercise
+
Stand
+ - + - + @@ -235,19 +247,22 @@

- +
Move
+
Exercise
+
Stand
+ - + - + @@ -260,19 +275,22 @@

- +
Move
+
Exercise
+
Stand
+ - + - + @@ -285,19 +303,22 @@

- +
Move
+
Exercise
+
Stand
+ - + - + @@ -335,22 +356,25 @@

<fitness-ring - move-total="item.move.total" move-goal="item.move.goal" - exercise-total="item.exercise.total" exercise-goal="item.exercise.goal" - stand-total="item.stand.total" move-goal="item.stand.goal" + calories-total="item.move.total" calories-goal="item.move.goal" + minutes-total="item.exercise.total" minutes-goal="item.exercise.goal" + hours-total="item.stand.total" hours-goal="item.stand.goal" ></fitness-ring> <fitness-card date="item.date" replayable="true" steps="item.steps" distance="item.distance" flights="item.flights" - move-total="item.move.total" move-goal="item.move.goal" - exercise-total="item.exercise.total" exercise-goal="item.exercise.goal" - stand-total="item.stand.total" move-goal="item.stand.goal" + calories-total="item.move.total" calories-goal="item.move.goal" + minutes-total="item.exercise.total" minutes-goal="item.exercise.goal" + hours-total="item.stand.total" hours-goal="item.stand.goal" > - <svg slot="icon-move"></svg> - <svg slot="icon-exercise"></svg> - <svg slot="icon-stand"></svg> + <div slot="calories">Move</div> + <div slot="minutes">Exercise</div> + <div slot="hours">Stand</div> + <svg slot="icon-calories"></svg> + <svg slot="icon-minutes"></svg> + <svg slot="icon-hours"></svg> </fitness-card>

The components above are driven by a JSON dataset that looks like the following.

diff --git a/js/FitnessCard.js b/js/FitnessCard.js deleted file mode 100644 index c1609ab..0000000 --- a/js/FitnessCard.js +++ /dev/null @@ -1,377 +0,0 @@ -import './FitnessRing.js'; - -export default class FitnessCard extends HTMLElement { - static observedAttributes = [ - 'date', - 'unit', - 'steps', - 'distance', - 'flights', - 'move-total', - 'move-goal', - 'exercise-goal', - 'exercise-total', - 'stand-goal', - 'stand-total', - ]; - - constructor() { - super(); - this.shadow = this.attachShadow({ mode: 'open' }); - } - - connectedCallback() { - const style = document.createElement('style'); - style.textContent = this.style(); - this.shadow.appendChild(style); - - const wrapper = document.createElement('div'); - wrapper.innerHTML = this.render(); - this.shadow.appendChild(wrapper); - - if ('IntersectionObserver' in window) { - this.observer = new IntersectionObserver( - elements => { - elements.forEach(element => { - if (element.isIntersecting) { - element.target.classList.add('visible'); - } else { - element.target.classList.remove('visible'); - } - }); - }, - { threshold: 0.5 } - ); - - this.observer.observe(wrapper); - } - } - - disconnectedCallback() { - this.observer.disconnect(); - } - - // Conversions. - number = number => Number(number).toLocaleString(); - - date = date => - new Date(date).toLocaleDateString(undefined, { - weekday: 'long', - year: 'numeric', - month: 'long', - day: 'numeric', - }); - - // Defaults. - units = () => this.getAttribute('units') ?? 'miles'; - - // Check attributes exist. - hasHeader = () => this.getAttribute('date'); - - hasFooter = () => - this.getAttribute('steps') || - this.getAttribute('distance') || - this.getAttribute('flights'); - - // Distance value and units. - distanceValue() { - switch (this.units()) { - case 'km': - case 'kilometres': - case 'kilometers': - return (this.getAttribute('distance') / 1000).toFixed(2); - - case 'mi': - case 'miles': - return (this.getAttribute('distance') / 1609.344).toFixed(2); - - default: - return this.getAttribute('distance'); - } - } - - distanceUnit() { - switch (this.units()) { - case 'km': - case 'kilometres': - case 'kilometers': - return 'Kilometres'; - - case 'mi': - case 'miles': - return 'Miles'; - - default: - return this.units(); - } - } - - distanceShorthand() { - switch (this.units()) { - case 'km': - case 'kilometres': - case 'kilometers': - return 'km'; - - case 'mi': - case 'miles': - return 'mi'; - - default: - return this.units(); - } - } - - // Fitness total/goal methods. - move = () => - `${this.number(this.getAttribute('move-total'))}/${this.number( - this.getAttribute('move-goal') - )}`; - - exercise = () => - `${this.number(this.getAttribute('exercise-total'))}/${this.number( - this.getAttribute('exercise-goal') - )}`; - - stand = () => - `${this.number(this.getAttribute('stand-total'))}/${this.number( - this.getAttribute('stand-goal') - )}`; - - style() { - return ` - :host { - --fitness-move: #fa114f; - --fitness-exercise: #92e82a; - --fitness-stand: #1eeaef; - --fitness-font: "SF Mono", "Monaco", "Inconsolata", "Fira Mono", "Droid Sans Mono", "Source Code Pro", monospace; - --fitness-value: inherit; - - display: block; - font-family: var(--fitness-font); - } - dl { - margin: 0; - line-height: 1.25; - text-align: center; - } - dl > div { - margin: 0 0 1.25rem; - letter-spacing: -0.075rem; - } - dl > div:last-child { - margin-bottom: 0; - } - dt { - margin: 0; - font-size: 1.4rem; - } - dd { - margin: 0; - font-size: 1.5rem; - font-variant-numeric: tabular-nums; - } - .text-value { - color: var(--fitness-value); - } - .text-move { - color: var(--fitness-move); - } - .text-exercise { - color: var(--fitness-exercise); - } - .text-stand { - color: var(--fitness-stand); - } - abbr { - font-size: 0.6em; - text-decoration: none; - text-transform: uppercase; - margin-left: 3px; - letter-spacing: 0; - } - [part="header"] { - display: block; - margin: 0 0 1rem; - padding: 1rem 0.5rem 0; - font-size: 1.25rem; - text-align: center; - } - [part="main"] { - display: flex; - margin: 1rem 0; - padding: 0 1rem; - flex-direction: column; - align-items: center; - justify-content: space-evenly; - } - [part="footer"] { - display: block; - margin: 1rem 0 0; - padding: 0 0.5rem 1rem; - } - [part="footer"] dl { - display: flex; - flex-direction: column; - items-align: center; - text-align: center; - justify-content: space-evenly; - border-top: 3px solid transparent; - } - fitness-ring { - margin-top: 1rem; - max-width: 360px; - } - - @media (min-width: 40rem) { - dl { - line-height: 1.1; - } - dt { - font-size: 1.4rem; - } - dd { - font-size: 1.5rem; - } - [part="header"] { - font-size: 1.66rem; - } - [part="main"] { - flex-direction: row; - } - [part="main"] dl { - text-align: left; - } - [part="footer"] dl { - flex-direction: row; - } - [part="footer"] dl > div { - margin-bottom: 0; - } - [part="footer"] dl dt { - margin-bottom: 0.25rem; - } - fitness-ring { - max-width: 45%; - margin-top: 0; - } - } - - @media (min-width: 54rem) { - dt { - font-size: 1.5rem; - } - dd { - font-size: 1.75rem; - } - fitness-ring { - max-width: 360px; - } - } - `; - } - - header = () => - `${ - this.hasHeader() ? this.date(this.getAttribute('date')) : '' - }`; - - stats = () => ` -
-
-
Move
-
- ${this.move()}Kcal -
-
- -
-
Exercise
-
- ${this.exercise()}min -
-
- -
-
Stand
-
- ${this.stand()}hrs -
-
-
- `; - - steps = () => - this.getAttribute('steps') - ? ` -
-
Steps
-
${this.number(this.getAttribute('steps'))}
-
- ` - : ''; - - distance = () => - this.getAttribute('distance') - ? ` -
-
Distance
-
${this.distanceValue()}${this.distanceShorthand()}
-
- ` - : ''; - - flights = () => - this.getAttribute('flights') - ? ` -
-
Flights
-
${this.number(this.getAttribute('flights'))}
-
- ` - : ''; - - footer = () => - this.hasFooter() - ? ` -
-
- ${this.steps()} - ${this.distance()} - ${this.flights()} -
-
- ` - : ''; - - render() { - return ` - ${this.header()} - -
- ${this.stats()} - - - - - - -
- - ${this.footer()} - `; - } -} - -if ('customElements' in window) { - window.customElements.define('fitness-card', FitnessCard); -} diff --git a/js/FitnessRing.js b/js/FitnessRing.js deleted file mode 100644 index 17ea9a3..0000000 --- a/js/FitnessRing.js +++ /dev/null @@ -1,241 +0,0 @@ -export default class FitnessRing extends HTMLElement { - static observedAttributes = [ - 'move-total', - 'move-goal', - 'exercise-goal', - 'exercise-total', - 'stand-goal', - 'stand-total', - ]; - - constructor() { - super(); - this.shadow = this.attachShadow({ mode: 'open' }); - } - - connectedCallback() { - const style = document.createElement('style'); - style.textContent = this.style(); - this.shadow.appendChild(style); - - const wrapper = document.createElement('div'); - wrapper.innerHTML = this.render(); - this.shadow.appendChild(wrapper); - - if ('IntersectionObserver' in window) { - this.observer = new IntersectionObserver( - elements => { - elements.forEach(element => { - if (element.isIntersecting) { - element.target.classList.add('visible'); - } - }); - }, - { threshold: 0.5 } - ); - - this.observer.observe(wrapper); - } else { - wrapper.classList.add('visible'); - } - - wrapper.addEventListener('click', () => { - if (this.replayable() && wrapper.classList.contains('complete')) { - wrapper.classList.add('reset'); - wrapper.classList.remove('complete'); - } - }); - - wrapper.addEventListener('animationstart', () => { - wrapper.classList.remove('complete'); - }); - - wrapper.addEventListener('animationend', () => { - if (wrapper.classList.contains('reset')) { - wrapper.classList.remove('reset'); - wrapper.classList.remove('visible'); - - void wrapper.offsetWidth; - wrapper.classList.add('visible'); - } else { - window.setTimeout(() => wrapper.classList.add('complete'), 50); - } - }); - } - - disconnectedCallback() { - this.observer.disconnect(); - } - - replayable =() => this.getAttribute('replayable') && this.getAttribute('replayable') === 'true'; - - percentage = (total = 0, goal = 100, max = 100) => - Math.min(Math.floor((total / goal) * 100), max); - - style() { - return ` - :host { - --fitness-ring-move: #fa114f; - --fitness-ring-exercise: #92e82a; - --fitness-ring-stand: #1eeaef; - - position: relative; - display: block; - width: 100%; - } - svg { - display: block; - } - g { - transform: rotate(-90deg); - transform-origin: center; - } - circle { - fill: transparent; - } - circle.base { - opacity: 0.25; - } - .move circle { - stroke: var(--fitness-move, var(--fitness-ring-move)); - transform: translate(50%, 50%); - } - .exercise circle { - stroke: var(--fitness-exercise, var(--fitness-ring-exercise)); - transform: translate(50%, 50%) scale(0.75); - } - .stand circle { - stroke: var(--fitness-stand, var(--fitness-ring-stand)); - transform: translate(50%, 50%) scale(0.5); - } - .visible circle:not(.base) { - animation: ease-in-out forwards ring; - } - .visible .move circle:not(.base) { - animation-delay: 50ms; - animation-duration: 1450ms; - } - .visible .exercise circle:not(.base) { - animation-delay: 300ms; - animation-duration: 1200ms; - } - .visible .stand circle:not(.base) { - animation-delay: 550ms; - animation-duration: 950ms; - } - .reset.reset.reset circle:not(.base) { - animation-delay: 0ms; - animation-duration: 650ms; - animation-fill-mode: backwards; - animation-name: ring-reverse; - } - .icons { - position: absolute; top: 0; right: 0; bottom: 0; left: 0; - } - .icons ::slotted(*) { - --fitness-icon: #fff; - - position: absolute; left: 50%; - margin-left: -3%; - height: 6%; width: 6%; - color: var(--fitness-icon); - fill: currentColor; - stroke: currentColor; - } - .icons ::slotted([slot="icon-move"]) { - top: 2.5%; - } - .icons ::slotted([slot="icon-exercise"]) { - top: 13.5%; - } - .icons ::slotted([slot="icon-stand"]) { - top: 25%; - } - @keyframes ring { - to { - stroke-dashoffset: 0; - } - } - @keyframes ring-reverse { - from { - stroke-dashoffset: 0; - } - } - @media (prefers-reduced-motion) { - .move circle, - .exercise circle, - .stand circle { - animation: none; - stroke-dashoffset: 0; - } - } - `; - } - - render() { - return ` - - - - - - - - - - - - - - - - - -
- - - -
- `; - } -} - -if ('customElements' in window) { - window.customElements.define('fitness-ring', FitnessRing); -}