From afc6dfc3dcd85d5c9cd494d6cf5c0a8094a9711f Mon Sep 17 00:00:00 2001 From: Eyitimonwa Akintokun Date: Mon, 13 Nov 2023 22:55:42 +0100 Subject: [PATCH] Improve kitchen sink (#829) * age calculator done * bmi calculator done * book recommendation done * calculator is done * countdown timer done * context done * currency converter done * data converter done * dice roller done * digital journal done * carousel done * discount calculator done * currency converter done * create event calender done * fix: fixed a merge issue * ran cleanup scripts --- .../src/css/examples/age-calculator.css | 17 + .../src/css/examples/bmi-calculator.css | 41 ++ .../src/css/examples/carousel.css | 18 + .../css/examples/create-event-calender.css | 315 +++++++++++++++ .../src/css/examples/dice-roller.css | 50 +++ .../src/{ => css/examples}/style.css | 381 ------------------ packages/kitchen-sink/src/css/style.css | 132 ++++++ .../src/examples/age-calculator.tsx | 117 +++--- .../src/examples/bmi-calculator.jsx | 244 +++-------- .../src/examples/book-recommendation.jsx | 225 ++++++----- .../kitchen-sink/src/examples/calculator.tsx | 2 - .../kitchen-sink/src/examples/carousel.tsx | 15 +- .../kitchen-sink/src/examples/context.tsx | 16 +- .../src/examples/countdown-timer.jsx | 253 ++++++------ .../src/examples/create-event-calender.jsx | 129 ++++++ .../src/examples/currency-convertor.tsx | 22 +- .../src/examples/data-converter.tsx | 18 +- .../kitchen-sink/src/examples/dice-roller.tsx | 1 + .../src/examples/digital-personal-journal.jsx | 54 ++- .../src/examples/discount-calculator.tsx | 12 +- packages/kitchen-sink/src/main.tsx | 3 +- website/liveblocks.config.ts | 2 +- 22 files changed, 1167 insertions(+), 900 deletions(-) create mode 100644 packages/kitchen-sink/src/css/examples/age-calculator.css create mode 100644 packages/kitchen-sink/src/css/examples/bmi-calculator.css create mode 100644 packages/kitchen-sink/src/css/examples/carousel.css create mode 100644 packages/kitchen-sink/src/css/examples/create-event-calender.css create mode 100644 packages/kitchen-sink/src/css/examples/dice-roller.css rename packages/kitchen-sink/src/{ => css/examples}/style.css (61%) create mode 100644 packages/kitchen-sink/src/css/style.css create mode 100644 packages/kitchen-sink/src/examples/create-event-calender.jsx diff --git a/packages/kitchen-sink/src/css/examples/age-calculator.css b/packages/kitchen-sink/src/css/examples/age-calculator.css new file mode 100644 index 0000000000..532c0a83a8 --- /dev/null +++ b/packages/kitchen-sink/src/css/examples/age-calculator.css @@ -0,0 +1,17 @@ +.age-calculator h2 { + font-size: 1.2rem; +} +.age-calculator .input-wrapper { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); + align-items: flex-end; + gap: 10px; +} +.age-calculator button { + margin-block: 20px; +} +.age-calculator .form-input-group { + display: flex; + flex-direction: column; + gap: 5px; +} diff --git a/packages/kitchen-sink/src/css/examples/bmi-calculator.css b/packages/kitchen-sink/src/css/examples/bmi-calculator.css new file mode 100644 index 0000000000..67c78946b3 --- /dev/null +++ b/packages/kitchen-sink/src/css/examples/bmi-calculator.css @@ -0,0 +1,41 @@ +.bmi-calculator { + max-width: 900px; +} +.bmi-calculator h2 { + text-align: center; +} +.bmi-calculator .bmi-calculator_wrapper { + max-width: 500px; + display: grid; + grid-template-columns: repeat(2, 1fr); + margin-inline: auto; + gap: 10px 20px; +} +@media screen and (max-width: 500px) { + .bmi-calculator .bmi-calculator_wrapper { + grid-template-columns: 1fr; + } +} +.bmi-calculator .form-input-group { + display: flex; + flex-direction: column; + justify-content: flex-end; + gap: 5px; +} +.bmi-calculator input, +.bmi-calculator select { + height: 40px; + color: currentColor; +} +.bmi-calculator select { + background-color: var(--background); + border: none; + border-radius: 5px; + padding: 8px; +} +.bmi-calculator button { + height: 40px; + color: black; + background-color: orange; + margin-top: 10px; +} diff --git a/packages/kitchen-sink/src/css/examples/carousel.css b/packages/kitchen-sink/src/css/examples/carousel.css new file mode 100644 index 0000000000..88fe75fbc4 --- /dev/null +++ b/packages/kitchen-sink/src/css/examples/carousel.css @@ -0,0 +1,18 @@ +/* Required styling for carousel */ +.carousel { + display: flex; + overflow: hidden; + gap: 10px; +} + +.carousel-inner { + display: flex; + width: 100%; + aspect-ratio: 3/2; + transition: transform 0.3s ease-in-out; +} +.carousel img { + width: 100%; + aspect-ratio: 3/2; + transition: transform 0.3s ease-in-out; +} diff --git a/packages/kitchen-sink/src/css/examples/create-event-calender.css b/packages/kitchen-sink/src/css/examples/create-event-calender.css new file mode 100644 index 0000000000..e4a515d138 --- /dev/null +++ b/packages/kitchen-sink/src/css/examples/create-event-calender.css @@ -0,0 +1,315 @@ +/* calendar styles */ +.create-event-calender { + /* text-align: center; */ +} + +.create-event-calender .create-event-calender_wrapper { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: flex-start; + margin-top: 2rem; +} + +.create-event-calender .calendar-container { + flex: 1; + max-width: 500px; + margin-right: 2rem; +} + +.create-event-calender .event-container { + flex: 1; + max-width: 500px; +} + +@media screen and (max-width: 768px) { + .create-event-calender .create-event-calender_wrapper { + flex-direction: column; + } + + .create-event-calender .calendar-container, + .create-event-calender .event-container { + max-width: 100%; + margin-right: 0; + margin-bottom: 2rem; + justify-content: center; + } +} + +.create-event-calender .react-calendar { + width: 100%; + max-width: 500px; + background-color: white; + border: 1px solid #151515; + font-family: Arial, Helvetica, sans-serif; + line-height: 1.125em; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + border-radius: 8px; + padding: 10px; + transition: background-color 0.2s; +} + +.create-event-calender .react-calendar--doubleView { + width: 100%; +} + +.create-event-calender + .react-calendar--doubleView + .react-calendar__viewContainer { + display: flex; + margin: -0.5em; +} + +.create-event-calender + .react-calendar--doubleView + .react-calendar__viewContainer + > * { + width: 50%; + margin: 0.5em; +} + +.create-event-calender .react-calendar, +.create-event-calender .react-calendar *, +.create-event-calender .react-calendar *:before, +.create-event-calender .react-calendar *:after { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +.create-event-calender .react-calendar button { + margin: 0; + border: 0; + outline: none; + color: #151515; +} + +.create-event-calender .react-calendar button:enabled:hover { + cursor: pointer; +} + +.create-event-calender .react-calendar__navigation { + display: flex; + height: 44px; + margin-bottom: 1em; +} + +.create-event-calender .react-calendar__navigation button { + min-width: 44px; + background: none; +} + +.create-event-calender .react-calendar__navigation button:disabled { + background-color: black; +} + +.create-event-calender .react-calendar__navigation button:enabled:hover, +.create-event-calender .react-calendar__navigation button:enabled:focus { + background-color: black; +} + +.create-event-calender .react-calendar__month-view__weekdays { + text-align: center; + text-transform: uppercase; + font-weight: bold; + font-size: 0.8rem; + color: black; +} + +.create-event-calender .react-calendar__month-view__weekdays__weekday { + padding: 0.5em; +} + +.create-event-calender + .react-calendar__month-view__weekNumbers + .react-calendar__tile { + display: flex; + align-items: center; + justify-content: center; + font-size: 0.75em; + font-weight: bold; +} + +.create-event-calender .react-calendar__month-view__days__day--weekend { + color: black; +} + +.create-event-calender + .react-calendar__month-view__days__day--neighboringMonth { + color: black; +} + +.create-event-calender .react-calendar__year-view .react-calendar__tile, +.create-event-calender .react-calendar__decade-view .react-calendar__tile, +.create-event-calender .react-calendar__century-view .react-calendar__tile { + padding: 2em 0.5em; +} + +.create-event-calender .react-calendar__tile { + max-width: 100%; + padding: 10px 6.6667px; + background: none; + text-align: center; + line-height: 16px; +} + +.create-event-calender .react-calendar__tile:disabled { + background-color: black; +} + +.create-event-calender .react-calendar__tile:enabled:hover, +.create-event-calender .react-calendar__tile:enabled:focus { + background-color: black; +} + +.create-event-calender .react-calendar__tile--now { + background: black; + color: white !important; +} + +.create-event-calender .react-calendar__tile--now:enabled:hover, +.create-event-calender .react-calendar__tile--now:enabled:focus { + background: black; +} + +.create-event-calender .react-calendar__tile--hasActive { + background: black; +} + +.create-event-calender .react-calendar__tile--hasActive:enabled:hover, +.create-event-calender .react-calendar__tile--hasActive:enabled:focus { + background: black; +} + +.create-event-calender .react-calendar__tile--active { + background: black; + color: black; +} + +.create-event-calender .react-calendar__tile--active:enabled:hover, +.create-event-calender .react-calendar__tile--active:enabled:focus { + background: black; +} + +.create-event-calender + .react-calendar--selectRange + .react-calendar__tile--hover { + background-color: black; +} + +.create-event-calender .event-form { + margin-bottom: 20px; +} + +.create-event-calender .event-form h2 { + margin-bottom: 10px; +} + +.create-event-calender .event-form p { + font-size: 1.2rem; +} + +.create-event-calender .event-form input { + padding: 8px; + font-size: 1rem; + margin-right: 10px; +} + +.create-event-calender .create-btn { + padding: 8px 6px; + margin-top: 5px; + background-color: white; + color: black; + border: 0.5px solid black; + border-radius: 4px; + font-size: 1rem; + cursor: pointer; + transition: background-color 0.2s; +} + +.create-event-calender .create-btn:hover { + background-color: black; + color: whitesmoke; + border: 0.5px solid white; +} + +.create-event-calender .event-list { + margin-top: 20px; +} + +.create-event-calender .event-cards { + display: flex; + flex-wrap: wrap; + justify-content: center; +} + +.create-event-calender .event-card { + width: 300px; + background-color: whitesmoke; + border-radius: 8px; + margin: 10px; + padding: 10px; + cursor: pointer; + transition: transform 0.2s, box-shadow 0.2s; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.create-event-calender .event-card:hover { + transform: translateY(-5px); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.create-event-calender .event-card-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 10px; +} + +.create-event-calender .event-date { + font-size: 1rem; + color: black; +} + +.create-event-calender .event-actions { + display: flex; +} + +.create-event-calender .update-btn, +.create-event-calender .delete-btn { + padding: 8px 12px; + margin-left: 5px; + background-color: white; + color: black; + border: 0.5px solid black; + border-radius: 4px; + font-size: 0.9rem; + cursor: pointer; + transition: background-color 0.2s; +} + +.create-event-calender .update-btn:hover, +.create-event-calender .delete-btn:hover { + background-color: black; + color: aliceblue; + border: 0.5px solid white; +} + +.create-event-calender .event-card-body { + padding-bottom: 10px; +} + +.create-event-calender .event-title { + font-size: 1.5rem; + color: blueviolet; +} + +.create-event-calender .selected { + background-color: #ff4081 !important; + color: black; +} + +.create-event-calender .event-marked { + background-color: #ff4081; + color: white; +} diff --git a/packages/kitchen-sink/src/css/examples/dice-roller.css b/packages/kitchen-sink/src/css/examples/dice-roller.css new file mode 100644 index 0000000000..a5420a8d2e --- /dev/null +++ b/packages/kitchen-sink/src/css/examples/dice-roller.css @@ -0,0 +1,50 @@ +/* Dice roller styles */ +@keyframes shakeDice { + 0% { + transform: translateX(0); + } + + 10% { + transform: translateX(-5px); + } + + 20% { + transform: translateX(5px); + } + + 30% { + transform: translateX(-5px); + } + + 40% { + transform: translateX(5px); + } + + 50% { + transform: translateX(-5px); + } + + 60% { + transform: translateX(5px); + } + + 70% { + transform: translateX(-5px); + } + + 80% { + transform: translateX(5px); + } + + 90% { + transform: translateX(-5px); + } + + 100% { + transform: translateX(0); + } +} + +.dice-roller.roll-animation { + animation: shakeDice 0.5s ease-in-out; +} diff --git a/packages/kitchen-sink/src/style.css b/packages/kitchen-sink/src/css/examples/style.css similarity index 61% rename from packages/kitchen-sink/src/style.css rename to packages/kitchen-sink/src/css/examples/style.css index 15bbf90ba0..5d6bd6f47a 100644 --- a/packages/kitchen-sink/src/style.css +++ b/packages/kitchen-sink/src/css/examples/style.css @@ -1,157 +1,3 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -:root { - font-family: 'Inter', sans-serif; -} - -@supports (font-variation-settings: normal) { - :root { - font-family: 'Inter var', sans-serif; - } -} - -.spinner { - width: 2rem; - height: 2rem; - border: 0.25rem solid #56c7ff; - border-bottom: 0.25rem solid rgba(0, 0, 0, 0); - border-radius: 50%; - animation: spin 1s linear infinite; - z-index: 9999; -} - -@keyframes spin { - to { - transform: rotate(360deg); - } -} - -button:disabled { - opacity: 0.2 !important; - cursor: not-allowed !important; -} - -.kitchen_sink-layout { - height: 100%; - margin-top: 1.5em; - display: flex; - max-width: 100vw; - overflow: hidden; -} - -.kitchen_sink-layout-icon { - outline: none; - border: none; - cursor: pointer; - position: relative; -} - -details { - margin: 0; -} - -.kitchen_sink-content { - width: 100%; - overflow-x: scroll; - -ms-overflow-style: none; - scrollbar-width: none; -} -.kitchen_sink-content::-webkit-scrollbar { - display: none; -} - -.kitchen_sink-content_container { - padding: 0; - width: 95%; - margin: 0 auto; - max-width: 1300px; - overflow-y: scroll; - -ms-overflow-style: none; - scrollbar-width: none; -} - -.kitchen_sink-content_container::-webkit-scrollbar { - display: none; -} -.kitchen_sink-sidebar { - height: 50vh; - border: 1px solid #353535; - box-shadow: 0px 4px 25px rgb(#000, 0.25); - overflow-y: scroll; - transition: all 200ms ease-in-out; - -ms-overflow-style: none; - scrollbar-width: none; - background: #252525; -} - -.kitchen_sink-sidebar_container { - display: flex; - flex-direction: column; - align-items: stretch; - justify-content: stretch; - gap: 1em; - overflow-y: scroll; -} - -.kitchen_sink-sidebar_close { - width: 0px; - overflow: hidden; - transition: all 200ms ease-in; -} - -.kitchen_sink-sidebar_open { - padding: 1em; - width: 320px; - min-width: 270px; -} - -@media screen and (max-width: 768px) { - .kitchen_sink-sidebar { - position: fixed; - z-index: 99999999; - top: 0; - left: 0; - height: 100vh; - } -} - -pre { - white-space: pre-wrap; - /* css-3 */ - white-space: -moz-pre-wrap; - /* Mozilla, since 1999 */ - white-space: -pre-wrap; - /* Opera 4-6 */ - white-space: -o-pre-wrap; - /* Opera 7 */ - word-wrap: break-word; - /* Internet Explorer 5.5+ */ -} - -/* Required styling for carousel */ -.carousel { - display: flex; - overflow: hidden; -} - -.carousel img { - width: 75%; - margin-right: 10px; - transition: transform 0.3s ease-in-out; -} - -.carousel-inner { - display: flex; - width: 75%; - height: auto; - margin: 0 10px 20px 0; - transition: transform 0.3s ease-in-out; -} - /* Music player styles */ .body { box-sizing: border-box; @@ -242,163 +88,6 @@ input[type='range'] { padding: 1rem; } -/* calendar styles */ - -.app { - text-align: center; - margin: 20px; -} - -.container { - display: flex; - flex-wrap: wrap; - justify-content: center; - align-items: flex-start; - margin-top: 2rem; -} - -.calendar-container { - flex: 1; - max-width: 500px; - margin-right: 2rem; -} - -.event-container { - flex: 1; - max-width: 500px; -} - -@media screen and (max-width: 768px) { - .container { - flex-direction: column; - } - - .calendar-container, - .event-container { - max-width: 100%; - margin-right: 0; - margin-bottom: 2rem; - justify-content: center; - } -} - -.event-form { - margin-bottom: 20px; -} - -.event-form h2 { - margin-bottom: 10px; -} - -.event-form p { - font-size: 1.2rem; -} - -.event-form input { - padding: 8px; - font-size: 1rem; - margin-right: 10px; -} - -.create-btn { - padding: 8px 6px; - margin-top: 5px; - background-color: white; - color: black; - border: 0.5px solid black; - border-radius: 4px; - font-size: 1rem; - cursor: pointer; - transition: background-color 0.2s; -} - -.create-btn:hover { - background-color: black; - color: whitesmoke; - border: 0.5px solid white; -} - -.event-list { - margin-top: 20px; -} - -.event-cards { - display: flex; - flex-wrap: wrap; - justify-content: center; -} - -.event-card { - width: 300px; - background-color: whitesmoke; - border-radius: 8px; - margin: 10px; - padding: 10px; - cursor: pointer; - transition: transform 0.2s, box-shadow 0.2s; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); -} - -.event-card:hover { - transform: translateY(-5px); - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); -} - -.event-card-header { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 10px; -} - -.event-date { - font-size: 1rem; - color: black; -} - -.event-actions { - display: flex; -} - -.update-btn, -.delete-btn { - padding: 8px 12px; - margin-left: 5px; - background-color: white; - color: black; - border: 0.5px solid black; - border-radius: 4px; - font-size: 0.9rem; - cursor: pointer; - transition: background-color 0.2s; -} - -.update-btn:hover, -.delete-btn:hover { - background-color: black; - color: aliceblue; - border: 0.5px solid white; -} - -.event-card-body { - padding-bottom: 10px; -} - -.event-title { - font-size: 1.5rem; - color: blueviolet; -} - -.selected { - background-color: #ff4081 !important; - color: black; -} - -.event-marked { - background-color: #ff4081; - color: white; -} - .news-card { display: flex; flex-direction: column; @@ -578,57 +267,6 @@ input[type='range'] { } } -/* Dice roller styles */ -@keyframes shakeDice { - 0% { - transform: translateX(0); - } - - 10% { - transform: translateX(-5px); - } - - 20% { - transform: translateX(5px); - } - - 30% { - transform: translateX(-5px); - } - - 40% { - transform: translateX(5px); - } - - 50% { - transform: translateX(-5px); - } - - 60% { - transform: translateX(5px); - } - - 70% { - transform: translateX(-5px); - } - - 80% { - transform: translateX(5px); - } - - 90% { - transform: translateX(-5px); - } - - 100% { - transform: translateX(0); - } -} - -.dice-roller.roll-animation { - animation: shakeDice 0.5s ease-in-out; -} - /* */ .container { @@ -833,25 +471,6 @@ input[type='range'] { background-color: #45a049; } -/* Age calculator styles */ - -.calculator-form { - display: flex; - flex-wrap: wrap; - align-items: flex-end; - gap: 10px; -} - -.calculator-form-input-wrapper { - display: flex; - flex-direction: column; - gap: 5px; -} - -.age { - font-size: 1.5rem; -} - /*Snake Game CSS*/ .snakeGame--main { height: 500px; diff --git a/packages/kitchen-sink/src/css/style.css b/packages/kitchen-sink/src/css/style.css new file mode 100644 index 0000000000..eeda1ed277 --- /dev/null +++ b/packages/kitchen-sink/src/css/style.css @@ -0,0 +1,132 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + font-family: 'Inter', sans-serif; +} + +@supports (font-variation-settings: normal) { + :root { + font-family: 'Inter var', sans-serif; + } +} + +.spinner { + width: 2rem; + height: 2rem; + border: 0.25rem solid #56c7ff; + border-bottom: 0.25rem solid rgba(0, 0, 0, 0); + border-radius: 50%; + animation: spin 1s linear infinite; + z-index: 9999; +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +button:disabled { + opacity: 0.2 !important; + cursor: not-allowed !important; +} + +.kitchen_sink-layout { + margin-top: 1.5em; + display: flex; + height: 100vh; + max-width: 100vw; + overflow: hidden; +} + +.kitchen_sink-layout-icon { + outline: none; + border: none; + cursor: pointer; + position: relative; +} + +.kitchen_sink-content { + width: 100%; + overflow-x: scroll; + -ms-overflow-style: none; + scrollbar-width: none; +} +.kitchen_sink-content::-webkit-scrollbar { + display: none; +} + +.kitchen_sink-content_container { + width: 95%; + margin: 0 auto; + max-width: 1300px; + height: 100vh; + overflow-y: scroll; + -ms-overflow-style: none; + scrollbar-width: none; +} + +.kitchen_sink-content_container::-webkit-scrollbar { + display: none; +} +.kitchen_sink-sidebar { + border: 1px solid #353535; + height: 100vh; + box-shadow: 0px 4px 25px rgb(#000, 0.25); + overflow-y: scroll; + transition: all 200ms ease-in-out; + -ms-overflow-style: none; + scrollbar-width: none; + background: #252525; +} + +.kitchen_sink-sidebar::-webkit-scrollbar { + display: none; +} + +.kitchen_sink-sidebar_container { + display: flex; + flex-direction: column; + align-items: stretch; + justify-content: stretch; + gap: 1em; + overflow-y: scroll; +} + +.kitchen_sink-sidebar_close { + width: 0px; + overflow: hidden; + transition: all 200ms ease-in; +} + +.kitchen_sink-sidebar_open { + padding: 1em; + width: 320px; + min-width: 270px; +} + +@media screen and (max-width: 768px) { + .kitchen_sink-sidebar { + position: fixed; + z-index: 99999999; + top: 0; + left: 0; + } +} + +pre { + white-space: pre-wrap; + /* css-3 */ + white-space: -moz-pre-wrap; + /* Mozilla, since 1999 */ + white-space: -pre-wrap; + /* Opera 4-6 */ + white-space: -o-pre-wrap; + /* Opera 7 */ + word-wrap: break-word; + /* Internet Explorer 5.5+ */ +} diff --git a/packages/kitchen-sink/src/examples/age-calculator.tsx b/packages/kitchen-sink/src/examples/age-calculator.tsx index fb9eeb8211..284b2220fc 100644 --- a/packages/kitchen-sink/src/examples/age-calculator.tsx +++ b/packages/kitchen-sink/src/examples/age-calculator.tsx @@ -1,5 +1,6 @@ import { useState } from 'react'; import { block } from 'million/react'; +import '../css/examples/age-calculator.css'; const AgeCalculator = block(() => { const Today = new Date(); @@ -45,66 +46,68 @@ const AgeCalculator = block(() => { } return ( -
-
- - - setBirthDay(e.target.value)} - maxLength={2} - pattern="(0?[1-9]|[12][0-9]|3[01])" - /> - - - - - setBirthMonth(e.target.value)} - maxLength={2} - pattern="(1[0-2]|0?[1-9])" - /> - - - - - setBirthYear(e.target.value)} - maxLength={4} - /> - - - -
- +
-

- {calculatedYear} {calculatedYear > 1 ? 'years' : 'year'} -

- -

- {calculatedMonth} {calculatedMonth > 1 ? 'months' : 'month'} -

+

Enter you date of birth

+
+
+ + + setBirthDay(e.target.value)} + maxLength={2} + min={1} + pattern="(0?[1-9]|[12][0-9]|3[01])" + /> + + + + + setBirthMonth(e.target.value)} + maxLength={2} + min={1} + pattern="(1[0-2]|0?[1-9])" + /> + + + + + setBirthYear(e.target.value)} + maxLength={4} + /> + +
+ + +
+
-

- {calculatedDay} {calculatedDay > 1 ? 'days' : 'day'} -

+
+

Your Age

+

+ You are {calculatedYear} {calculatedYear > 1 ? 'years' : 'year'},{' '} + {calculatedMonth} {calculatedMonth > 1 ? 'months' : 'month'} and{' '} + {calculatedDay} {calculatedDay > 1 ? 'days' : 'day'} old. +

-
+ ); }); diff --git a/packages/kitchen-sink/src/examples/bmi-calculator.jsx b/packages/kitchen-sink/src/examples/bmi-calculator.jsx index f4590bcdb2..bd47d2ac1d 100644 --- a/packages/kitchen-sink/src/examples/bmi-calculator.jsx +++ b/packages/kitchen-sink/src/examples/bmi-calculator.jsx @@ -1,7 +1,8 @@ import React, { useState } from 'react'; import { block } from 'million/react'; +import '../css/examples/bmi-calculator.css'; -const BmiCalculator = block(() => { +const BmiCalculator = block(function BmiComponent() { const [age, setAge] = useState(''); const [gender, setGender] = useState('male'); const [heightFeet, setHeightFeet] = useState(''); @@ -43,208 +44,89 @@ const BmiCalculator = block(() => { }; return ( -
-

BMI Calculator

-
-
-
- - setAge(e.target.value)} - /> -
- -
- - -
+
+

BMI Calculator

+
+
+ + setAge(e.target.value)} + />
-
-
-
-
- - setHeightFeet(e.target.value)} - /> -
+
+ + +
-
- - setHeightInches(e.target.value)} - /> -
+
+ + setHeightFeet(e.target.value)} + min={1} + />
-
-
-
-
- - setWeight(e.target.value)} - /> -
+
+ + setHeightInches(e.target.value)} + min={1} + /> +
-
- - -
+
+ + setWeight(e.target.value)} + min={1} + /> +
+
+
{errorMessage && ( -

- {errorMessage} -

+

{errorMessage}

)} {bmi !== null && (
-

- Your BMI: {bmi} +

+ Your BMI: {bmi}

-

- Category: {bmiCategory} +

+ Category: {bmiCategory}

)} -
+
); }); diff --git a/packages/kitchen-sink/src/examples/book-recommendation.jsx b/packages/kitchen-sink/src/examples/book-recommendation.jsx index 7414086194..dfce13652d 100644 --- a/packages/kitchen-sink/src/examples/book-recommendation.jsx +++ b/packages/kitchen-sink/src/examples/book-recommendation.jsx @@ -40,90 +40,94 @@ const BookRecommendation = block(() => { return (
+

+ Reading makes the world huge +

+
-

- Reading makes the world huge -

-
-
+

Find Something to read

+

+ Fancy something unusual and unpredictable? Funny or exciting? No + problem. Check out the collections we have prepared for you. +

+ - - - -
-
- book image + + -
+ +
+
+ book image
+ + +
- -
-
-

Bestsellers

+

+ Bestsellers +

{books.map((book, index) => ( @@ -145,44 +149,46 @@ const BookRecommendation = block(() => { const Book = ({ author, image, title, url }) => { return ( -
-
+ +
+ {author || 'Murakami'} +
+

{title || 'After Dark'}

+ + - {title} -
- -
+ See more + + ); }; @@ -211,12 +217,23 @@ const Subject = block(({ selectedSubject, onSelectSubject }) => { ]; return ( - <> +
{SUBJECTS.map((subject) => ( ))} - +
); }); diff --git a/packages/kitchen-sink/src/examples/calculator.tsx b/packages/kitchen-sink/src/examples/calculator.tsx index 2fcf55bad8..593f68b711 100644 --- a/packages/kitchen-sink/src/examples/calculator.tsx +++ b/packages/kitchen-sink/src/examples/calculator.tsx @@ -50,7 +50,6 @@ const Screen = block(({ value, newValue, operator }: ICalculator) => { >

{

{ const [images, setImages] = useState([]); @@ -37,19 +38,19 @@ const Carousel = block(() => {

{images.map((image) => ( {image.author} ))}
- - +
+ + +
); }); diff --git a/packages/kitchen-sink/src/examples/context.tsx b/packages/kitchen-sink/src/examples/context.tsx index 5720734900..0b87f29499 100644 --- a/packages/kitchen-sink/src/examples/context.tsx +++ b/packages/kitchen-sink/src/examples/context.tsx @@ -3,11 +3,19 @@ import { block } from 'million/react'; const ThemeContext = createContext('light'); -const Context = block(() => { +const Context = block(({onClick}) => { const theme = useContext(ThemeContext); return ( -
{theme}
+ ); }); @@ -16,9 +24,7 @@ const App = block(() => { return ( - + setTheme(theme === 'light' ? 'dark' : 'light')} /> ); }); diff --git a/packages/kitchen-sink/src/examples/countdown-timer.jsx b/packages/kitchen-sink/src/examples/countdown-timer.jsx index aea825caf3..edf6f9b996 100644 --- a/packages/kitchen-sink/src/examples/countdown-timer.jsx +++ b/packages/kitchen-sink/src/examples/countdown-timer.jsx @@ -5,7 +5,7 @@ import StopSVG from '../../assets/stop.svg'; import FlagSVG from '../../assets/flag.svg'; import ResetSVG from '../../assets/close.svg'; -const CountdownTimer = block(function TimerComponent() { +const CountDownTimer = block(function TimerComponent() { const [hours, setHours] = useState(0); const [minutes, setMinutes] = useState(0); const [seconds, setSeconds] = useState(0); @@ -96,162 +96,141 @@ const CountdownTimer = block(function TimerComponent() { }, [isRunning, hours, minutes, seconds, milliseconds]); return ( -
-
-
-

- {`${hours.toString().padStart(2, '0')}:${minutes - .toString() - .padStart(2, '0')}:${seconds - .toString() - .padStart(2, '0')}:${milliseconds.toString().padStart(2, '0')}`} -

-
- +
+

+ {`${hours.toString().padStart(2, '0')}:${minutes + .toString() + .padStart(2, '0')}:${seconds + .toString() + .padStart(2, '0')}:${milliseconds.toString().padStart(2, '0')}`} +

+ +
-
-
- - -
- -
- - -
-
- -
- - - - - - - -
+ +
-
    - {recordedTimes.map((time, index) => ( -
  • {time}
  • - ))} -
+ +
+
+ +
+ + + + +
+ +
+
    + {recordedTimes.map((time, index) => ( +
  • {time}
  • + ))} +
{recordedTimes.length > 0 && ( -
- -
+ Clear + )} -
-
+
+
); }); -export default CountdownTimer; +export default CountDownTimer; diff --git a/packages/kitchen-sink/src/examples/create-event-calender.jsx b/packages/kitchen-sink/src/examples/create-event-calender.jsx new file mode 100644 index 0000000000..398bbffe8d --- /dev/null +++ b/packages/kitchen-sink/src/examples/create-event-calender.jsx @@ -0,0 +1,129 @@ +import { useState, useRef } from 'react'; +import Calendar from 'react-calendar'; +import 'react-calendar/dist/Calendar.css'; +import { block } from 'million/react'; +import '../css/examples/create-event-calender.css'; + +const EventCalender = block(() => { + const [selectedDate, setSelectedDate] = useState(null); + const [events, setEvents] = useState([]); + const inputRef = useRef(null); + + const Date_Click_Fun = (date) => { + setSelectedDate(date); + }; + + const Create_Event_Fun = () => { + if (selectedDate && inputRef) { + const newEvent = { + id: new Date().getTime(), + date: selectedDate, + title: inputRef.current.value, + }; + setEvents([...events, newEvent]); + setSelectedDate(null); + inputRef.current.value = ''; + setSelectedDate(newEvent.date); + } + }; + + const Update_Event_Fun = (eventId, newName) => { + const updated_Events = events.map((event) => { + if (event.id === eventId) { + return { + ...event, + title: newName, + }; + } + return event; + }); + setEvents(updated_Events); + }; + + const Delete_Event_Fun = (eventId) => { + const updated_Events = events.filter((event) => event.id !== eventId); + setEvents(updated_Events); + }; + + return ( +
+

Create an Event Calendar Application

+
+
+ + selectedDate && + date.toDateString() === selectedDate.toDateString() + ? 'selected' + : events.some( + (event) => + event.date.toDateString() === date.toDateString(), + ) + ? 'event-marked' + : '' + } + />{' '} +
+
+ {' '} + {selectedDate && ( +
+

Create Event

{' '} +

Selected Date: {selectedDate.toDateString()}

{' '} + + {' '} +
+ )} + {events.length > 0 && selectedDate && ( +
+

My Created Event List

{' '} +
+ {' '} + {events.map((event) => + event.date.toDateString() === selectedDate.toDateString() ? ( +
+
+ + {' '} + {event.date.toDateString()}{' '} + {' '} +
+ {' '} + {' '} +
{' '} +
{' '} +
+

{event.title}

{' '} +
{' '} +
+ ) : null, + )}{' '} +
{' '} +
+ )}{' '} +
+
+
+ ); +}); + +export default EventCalender; diff --git a/packages/kitchen-sink/src/examples/currency-convertor.tsx b/packages/kitchen-sink/src/examples/currency-convertor.tsx index 4040de24ac..6d4e86a2ad 100644 --- a/packages/kitchen-sink/src/examples/currency-convertor.tsx +++ b/packages/kitchen-sink/src/examples/currency-convertor.tsx @@ -10,6 +10,7 @@ interface CurrencyInputProps { currencies?: string[]; onAmountChange?: (amount: number) => void; onCurrencyChange?: (currency: string) => void; + title: string; } function CurrencyConvertor() { const [amount1, setAmount1] = useState(1); @@ -72,15 +73,19 @@ function CurrencyConvertor() { textAlign: 'center', }} > -

Currency Converter

+

Currency Converter

+ + { return (
+

+ Currency {props?.title}: {props.currency} +

props.onAmountChange?.(parseFloat(ev.target.value))} /> @@ -112,6 +125,11 @@ const CurrencyInput = block((props: CurrencyInputProps) => { padding: '10px 10px', margin: '5px 5px', outline: 'none', + height: '40px', + color: 'currentcolor', + backgroundColor: ' var(--background)', + minWidth: '50px', + border: 'none', }} value={props.currency} onChange={(ev) => props.onCurrencyChange?.(ev.target.value)} diff --git a/packages/kitchen-sink/src/examples/data-converter.tsx b/packages/kitchen-sink/src/examples/data-converter.tsx index fb92d30fbc..83ed408204 100644 --- a/packages/kitchen-sink/src/examples/data-converter.tsx +++ b/packages/kitchen-sink/src/examples/data-converter.tsx @@ -51,19 +51,20 @@ const DataConverter: React.FC = block(() => { }; return ( -
-

Data Converter

+

Data Converter

{ padding: '10px 10px', margin: '5px 5px', outline: 'none', + color: 'currentcolor', + backgroundColor: ' var(--background)', + border: 'none', + height: '40px', }} value={state.inputUnit} onChange={handleInputUnitChange} @@ -94,10 +99,13 @@ const DataConverter: React.FC = block(() => { borderRadius: '10px', padding: '10px 10px', margin: '5px 5px', + height: '40px', + cursor: 'not-allowed', }} type="number" value={state.convertedValue} disabled + /> setTitle(e.target.value)} - style={{ display: 'block', marginBottom: '15px' }} + style={{ + display: 'block', + marginBottom: '15px', + width: '100%', + maxWidth: '500px', + }} /> - setText(e.target.value)} - style={{ display: 'block', marginBottom: '15px' }} - /> + style={{ + display: 'block', + marginBottom: '15px', + width: '100%', + maxWidth: '500px', + color: 'currentcolor', + backgroundColor: ' var(--background)', + border: 'none', + borderRadius: '4px', + padding: '10px', + fontSize: 'inherit', + }} + > setMediaFile(e.target.files[0])} - style={{ display: 'block', marginBottom: '15px' }} + style={{ + display: 'block', + marginBottom: '15px', + width: '100%', + maxWidth: '250px', + }} ref={fileInputRef} />
@@ -144,7 +172,7 @@ const DigitalPersonalJournal = block(function Journal() { /> ))}
-
+ ); }); diff --git a/packages/kitchen-sink/src/examples/discount-calculator.tsx b/packages/kitchen-sink/src/examples/discount-calculator.tsx index 1b58511460..9790da4231 100644 --- a/packages/kitchen-sink/src/examples/discount-calculator.tsx +++ b/packages/kitchen-sink/src/examples/discount-calculator.tsx @@ -31,29 +31,29 @@ const DiscountCalculator = block(() => { return (
-

Discount Calculator

-
+

Discount Calculator

+
setOriginalPrice(e.target.value)} - style={{ display: 'block', marginBottom: '15px' }} + style={{ display: 'block' }} />
-
+
setDiscountRate(e.target.value)} - style={{ display: 'block', marginBottom: '15px' }} + style={{ display: 'block' }} />
{results && ( -
+

Results:

Final Price : ${results.finalPrice.toFixed(2)}
You Save : ${results.discountPrice.toFixed(2)}
diff --git a/packages/kitchen-sink/src/main.tsx b/packages/kitchen-sink/src/main.tsx index f6fc2d6562..e280d3d2c4 100644 --- a/packages/kitchen-sink/src/main.tsx +++ b/packages/kitchen-sink/src/main.tsx @@ -6,7 +6,8 @@ import { LazyExoticComponent, useEffect, } from 'react'; -import './style.css'; +import './css/style.css'; +import './css/examples/style.css'; import { ErrorBoundary } from 'react-error-boundary'; import { RxHamburgerMenu } from 'react-icons/rx'; import { AiOutlineClose } from 'react-icons/ai'; diff --git a/website/liveblocks.config.ts b/website/liveblocks.config.ts index a8072cd2c0..824bd6e0b2 100644 --- a/website/liveblocks.config.ts +++ b/website/liveblocks.config.ts @@ -1,6 +1,6 @@ import { createClient } from '@liveblocks/client'; import { createRoomContext } from '@liveblocks/react'; -import type { JsonObject} from '@liveblocks/client'; +import type { JsonObject } from '@liveblocks/client'; const client = createClient({ throttle: 16,