From 29cbb83a09e40b6f67623aada54d3b1e5a2eb47f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 19 Aug 2021 21:21:26 +0800 Subject: [PATCH] chore: snapshot --- playground/default/src/App.vue | 45 ++---- playground/default/src/assets/base.css | 2 +- .../src/components/ColorSchemeSwitch.vue | 2 +- .../default/src/components/HelloWorld.vue | 2 +- .../src/components/IntroductionItem.vue | 3 +- .../cypress/integration/example.spec.js | 2 +- .../jsx-router-vuex-with-tests/src/App.vue | 118 +++++++++++++-- .../src/assets/base.css | 72 +++++++++ .../src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../__tests__/ColorSchemeSwitch.spec.js | 34 +++++ .../components/__tests__/HelloWorld.spec.js | 9 -- .../src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../src/components/icons/Ecosystem.vue | 7 + .../src/components/icons/Moon.vue | 18 +++ .../src/components/icons/Sun.vue | 34 +++++ .../src/components/icons/Support.vue | 7 + .../src/components/icons/Tooling.vue | 19 +++ .../__tests__/useMediaQuery.spec.js | 33 +++++ .../src/composables/useColorScheme.js | 31 ++++ .../src/composables/useMediaQuery.js | 28 ++++ .../src/views/About.vue | 10 ++ .../src/views/Home.vue | 101 +++++++++++-- playground/jsx-router-vuex/src/App.vue | 118 +++++++++++++-- .../jsx-router-vuex/src/assets/base.css | 72 +++++++++ .../jsx-router-vuex/src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../src/components/icons/Ecosystem.vue | 7 + .../src/components/icons/Moon.vue | 18 +++ .../src/components/icons/Sun.vue | 34 +++++ .../src/components/icons/Support.vue | 7 + .../src/components/icons/Tooling.vue | 19 +++ .../src/composables/useColorScheme.js | 31 ++++ .../src/composables/useMediaQuery.js | 28 ++++ .../jsx-router-vuex/src/views/About.vue | 10 ++ playground/jsx-router-vuex/src/views/Home.vue | 101 +++++++++++-- playground/jsx-router/src/App.vue | 118 +++++++++++++-- playground/jsx-router/src/assets/base.css | 72 +++++++++ playground/jsx-router/src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../jsx-router/src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../src/components/icons/Ecosystem.vue | 7 + .../jsx-router/src/components/icons/Moon.vue | 18 +++ .../jsx-router/src/components/icons/Sun.vue | 34 +++++ .../src/components/icons/Support.vue | 7 + .../src/components/icons/Tooling.vue | 19 +++ .../src/composables/useColorScheme.js | 31 ++++ .../src/composables/useMediaQuery.js | 28 ++++ playground/jsx-router/src/views/About.vue | 10 ++ playground/jsx-router/src/views/Home.vue | 101 +++++++++++-- playground/jsx/src/App.vue | 45 ++---- playground/jsx/src/assets/base.css | 2 +- .../jsx/src/components/ColorSchemeSwitch.vue | 2 +- playground/jsx/src/components/HelloWorld.vue | 2 +- .../jsx/src/components/IntroductionItem.vue | 3 +- .../cypress/integration/example.spec.js | 2 +- playground/router-vuex-with-tests/src/App.vue | 118 +++++++++++++-- .../src/assets/base.css | 72 +++++++++ .../src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../__tests__/ColorSchemeSwitch.spec.js | 34 +++++ .../components/__tests__/HelloWorld.spec.js | 9 -- .../src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../src/components/icons/Ecosystem.vue | 7 + .../src/components/icons/Moon.vue | 18 +++ .../src/components/icons/Sun.vue | 34 +++++ .../src/components/icons/Support.vue | 7 + .../src/components/icons/Tooling.vue | 19 +++ .../__tests__/useMediaQuery.spec.js | 33 +++++ .../src/composables/useColorScheme.js | 31 ++++ .../src/composables/useMediaQuery.js | 28 ++++ .../src/views/About.vue | 10 ++ .../router-vuex-with-tests/src/views/Home.vue | 101 +++++++++++-- playground/router-vuex/src/App.vue | 118 +++++++++++++-- playground/router-vuex/src/assets/base.css | 72 +++++++++ playground/router-vuex/src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../router-vuex/src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../src/components/icons/Ecosystem.vue | 7 + .../router-vuex/src/components/icons/Moon.vue | 18 +++ .../router-vuex/src/components/icons/Sun.vue | 34 +++++ .../src/components/icons/Support.vue | 7 + .../src/components/icons/Tooling.vue | 19 +++ .../src/composables/useColorScheme.js | 31 ++++ .../src/composables/useMediaQuery.js | 28 ++++ playground/router-vuex/src/views/About.vue | 10 ++ playground/router-vuex/src/views/Home.vue | 101 +++++++++++-- playground/router/src/App.vue | 118 +++++++++++++-- playground/router/src/assets/base.css | 72 +++++++++ playground/router/src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../router/src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../router/src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../router/src/components/icons/Ecosystem.vue | 7 + .../router/src/components/icons/Moon.vue | 18 +++ .../router/src/components/icons/Sun.vue | 34 +++++ .../router/src/components/icons/Support.vue | 7 + .../router/src/components/icons/Tooling.vue | 19 +++ .../router/src/composables/useColorScheme.js | 31 ++++ .../router/src/composables/useMediaQuery.js | 28 ++++ playground/router/src/views/About.vue | 10 ++ playground/router/src/views/Home.vue | 101 +++++++++++-- .../cypress/integration/example.spec.ts | 2 +- .../src/App.vue | 118 +++++++++++++-- .../src/assets/base.css | 72 +++++++++ .../src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../__tests__/ColorSchemeSwitch.spec.ts | 34 +++++ .../components/__tests__/HelloWorld.spec.ts | 9 -- .../src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../src/components/icons/Ecosystem.vue | 7 + .../src/components/icons/Moon.vue | 18 +++ .../src/components/icons/Sun.vue | 34 +++++ .../src/components/icons/Support.vue | 7 + .../src/components/icons/Tooling.vue | 19 +++ .../__tests__/useMediaQuery.spec.ts | 33 +++++ .../src/composables/useColorScheme.ts | 31 ++++ .../src/composables/useMediaQuery.ts | 28 ++++ .../src/views/About.vue | 10 ++ .../src/views/Home.vue | 101 +++++++++++-- .../typescript-jsx-router-vuex/src/App.vue | 118 +++++++++++++-- .../src/assets/base.css | 72 +++++++++ .../src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../src/components/icons/Ecosystem.vue | 7 + .../src/components/icons/Moon.vue | 18 +++ .../src/components/icons/Sun.vue | 34 +++++ .../src/components/icons/Support.vue | 7 + .../src/components/icons/Tooling.vue | 19 +++ .../src/composables/useColorScheme.ts | 31 ++++ .../src/composables/useMediaQuery.ts | 28 ++++ .../src/views/About.vue | 10 ++ .../src/views/Home.vue | 101 +++++++++++-- playground/typescript-jsx-router/src/App.vue | 118 +++++++++++++-- .../typescript-jsx-router/src/assets/base.css | 72 +++++++++ .../typescript-jsx-router/src/assets/logo.svg | 1 + .../src/components/ColorSchemeSwitch.vue | 137 ++++++++++++++++++ .../src/components/HelloWorld.vue | 69 ++++----- .../src/components/IntroductionItem.vue | 86 +++++++++++ .../src/components/icons/Community.vue | 7 + .../src/components/icons/Documentation.vue | 7 + .../src/components/icons/Ecosystem.vue | 7 + .../src/components/icons/Moon.vue | 18 +++ .../src/components/icons/Sun.vue | 34 +++++ .../src/components/icons/Support.vue | 7 + .../src/components/icons/Tooling.vue | 19 +++ .../src/composables/useColorScheme.ts | 31 ++++ .../src/composables/useMediaQuery.ts | 28 ++++ .../typescript-jsx-router/src/views/About.vue | 10 ++ .../typescript-jsx-router/src/views/Home.vue | 101 +++++++++++-- playground/typescript-jsx/src/App.vue | 45 ++---- playground/typescript-jsx/src/assets/base.css | 2 +- .../src/components/ColorSchemeSwitch.vue | 2 +- .../src/components/HelloWorld.vue | 2 +- .../src/components/IntroductionItem.vue | 3 +- playground/typescript/src/App.vue | 45 ++---- playground/typescript/src/assets/base.css | 2 +- .../src/components/ColorSchemeSwitch.vue | 2 +- .../typescript/src/components/HelloWorld.vue | 2 +- .../src/components/IntroductionItem.vue | 3 +- playground/vuex-with-tests/src/App.vue | 45 ++---- .../vuex-with-tests/src/assets/base.css | 2 +- .../src/components/ColorSchemeSwitch.vue | 2 +- .../src/components/HelloWorld.vue | 2 +- .../src/components/IntroductionItem.vue | 3 +- playground/vuex/src/App.vue | 45 ++---- playground/vuex/src/assets/base.css | 2 +- .../vuex/src/components/ColorSchemeSwitch.vue | 2 +- playground/vuex/src/components/HelloWorld.vue | 2 +- .../vuex/src/components/IntroductionItem.vue | 3 +- playground/with-tests/src/App.vue | 45 ++---- playground/with-tests/src/assets/base.css | 2 +- .../src/components/ColorSchemeSwitch.vue | 2 +- .../with-tests/src/components/HelloWorld.vue | 2 +- .../src/components/IntroductionItem.vue | 3 +- 200 files changed, 6438 insertions(+), 942 deletions(-) create mode 100644 playground/jsx-router-vuex-with-tests/src/assets/base.css create mode 100644 playground/jsx-router-vuex-with-tests/src/assets/logo.svg create mode 100644 playground/jsx-router-vuex-with-tests/src/components/ColorSchemeSwitch.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/components/IntroductionItem.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.js create mode 100644 playground/jsx-router-vuex-with-tests/src/components/icons/Community.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/components/icons/Documentation.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/components/icons/Ecosystem.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/components/icons/Moon.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/components/icons/Sun.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/components/icons/Support.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/components/icons/Tooling.vue create mode 100644 playground/jsx-router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.js create mode 100644 playground/jsx-router-vuex-with-tests/src/composables/useColorScheme.js create mode 100644 playground/jsx-router-vuex-with-tests/src/composables/useMediaQuery.js create mode 100644 playground/jsx-router-vuex/src/assets/base.css create mode 100644 playground/jsx-router-vuex/src/assets/logo.svg create mode 100644 playground/jsx-router-vuex/src/components/ColorSchemeSwitch.vue create mode 100644 playground/jsx-router-vuex/src/components/IntroductionItem.vue create mode 100644 playground/jsx-router-vuex/src/components/icons/Community.vue create mode 100644 playground/jsx-router-vuex/src/components/icons/Documentation.vue create mode 100644 playground/jsx-router-vuex/src/components/icons/Ecosystem.vue create mode 100644 playground/jsx-router-vuex/src/components/icons/Moon.vue create mode 100644 playground/jsx-router-vuex/src/components/icons/Sun.vue create mode 100644 playground/jsx-router-vuex/src/components/icons/Support.vue create mode 100644 playground/jsx-router-vuex/src/components/icons/Tooling.vue create mode 100644 playground/jsx-router-vuex/src/composables/useColorScheme.js create mode 100644 playground/jsx-router-vuex/src/composables/useMediaQuery.js create mode 100644 playground/jsx-router/src/assets/base.css create mode 100644 playground/jsx-router/src/assets/logo.svg create mode 100644 playground/jsx-router/src/components/ColorSchemeSwitch.vue create mode 100644 playground/jsx-router/src/components/IntroductionItem.vue create mode 100644 playground/jsx-router/src/components/icons/Community.vue create mode 100644 playground/jsx-router/src/components/icons/Documentation.vue create mode 100644 playground/jsx-router/src/components/icons/Ecosystem.vue create mode 100644 playground/jsx-router/src/components/icons/Moon.vue create mode 100644 playground/jsx-router/src/components/icons/Sun.vue create mode 100644 playground/jsx-router/src/components/icons/Support.vue create mode 100644 playground/jsx-router/src/components/icons/Tooling.vue create mode 100644 playground/jsx-router/src/composables/useColorScheme.js create mode 100644 playground/jsx-router/src/composables/useMediaQuery.js create mode 100644 playground/router-vuex-with-tests/src/assets/base.css create mode 100644 playground/router-vuex-with-tests/src/assets/logo.svg create mode 100644 playground/router-vuex-with-tests/src/components/ColorSchemeSwitch.vue create mode 100644 playground/router-vuex-with-tests/src/components/IntroductionItem.vue create mode 100644 playground/router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.js create mode 100644 playground/router-vuex-with-tests/src/components/icons/Community.vue create mode 100644 playground/router-vuex-with-tests/src/components/icons/Documentation.vue create mode 100644 playground/router-vuex-with-tests/src/components/icons/Ecosystem.vue create mode 100644 playground/router-vuex-with-tests/src/components/icons/Moon.vue create mode 100644 playground/router-vuex-with-tests/src/components/icons/Sun.vue create mode 100644 playground/router-vuex-with-tests/src/components/icons/Support.vue create mode 100644 playground/router-vuex-with-tests/src/components/icons/Tooling.vue create mode 100644 playground/router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.js create mode 100644 playground/router-vuex-with-tests/src/composables/useColorScheme.js create mode 100644 playground/router-vuex-with-tests/src/composables/useMediaQuery.js create mode 100644 playground/router-vuex/src/assets/base.css create mode 100644 playground/router-vuex/src/assets/logo.svg create mode 100644 playground/router-vuex/src/components/ColorSchemeSwitch.vue create mode 100644 playground/router-vuex/src/components/IntroductionItem.vue create mode 100644 playground/router-vuex/src/components/icons/Community.vue create mode 100644 playground/router-vuex/src/components/icons/Documentation.vue create mode 100644 playground/router-vuex/src/components/icons/Ecosystem.vue create mode 100644 playground/router-vuex/src/components/icons/Moon.vue create mode 100644 playground/router-vuex/src/components/icons/Sun.vue create mode 100644 playground/router-vuex/src/components/icons/Support.vue create mode 100644 playground/router-vuex/src/components/icons/Tooling.vue create mode 100644 playground/router-vuex/src/composables/useColorScheme.js create mode 100644 playground/router-vuex/src/composables/useMediaQuery.js create mode 100644 playground/router/src/assets/base.css create mode 100644 playground/router/src/assets/logo.svg create mode 100644 playground/router/src/components/ColorSchemeSwitch.vue create mode 100644 playground/router/src/components/IntroductionItem.vue create mode 100644 playground/router/src/components/icons/Community.vue create mode 100644 playground/router/src/components/icons/Documentation.vue create mode 100644 playground/router/src/components/icons/Ecosystem.vue create mode 100644 playground/router/src/components/icons/Moon.vue create mode 100644 playground/router/src/components/icons/Sun.vue create mode 100644 playground/router/src/components/icons/Support.vue create mode 100644 playground/router/src/components/icons/Tooling.vue create mode 100644 playground/router/src/composables/useColorScheme.js create mode 100644 playground/router/src/composables/useMediaQuery.js create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/assets/base.css create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/assets/logo.svg create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/ColorSchemeSwitch.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/IntroductionItem.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.ts create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Community.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Documentation.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Ecosystem.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Moon.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Sun.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Support.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Tooling.vue create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.ts create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/composables/useColorScheme.ts create mode 100644 playground/typescript-jsx-router-vuex-with-tests/src/composables/useMediaQuery.ts create mode 100644 playground/typescript-jsx-router-vuex/src/assets/base.css create mode 100644 playground/typescript-jsx-router-vuex/src/assets/logo.svg create mode 100644 playground/typescript-jsx-router-vuex/src/components/ColorSchemeSwitch.vue create mode 100644 playground/typescript-jsx-router-vuex/src/components/IntroductionItem.vue create mode 100644 playground/typescript-jsx-router-vuex/src/components/icons/Community.vue create mode 100644 playground/typescript-jsx-router-vuex/src/components/icons/Documentation.vue create mode 100644 playground/typescript-jsx-router-vuex/src/components/icons/Ecosystem.vue create mode 100644 playground/typescript-jsx-router-vuex/src/components/icons/Moon.vue create mode 100644 playground/typescript-jsx-router-vuex/src/components/icons/Sun.vue create mode 100644 playground/typescript-jsx-router-vuex/src/components/icons/Support.vue create mode 100644 playground/typescript-jsx-router-vuex/src/components/icons/Tooling.vue create mode 100644 playground/typescript-jsx-router-vuex/src/composables/useColorScheme.ts create mode 100644 playground/typescript-jsx-router-vuex/src/composables/useMediaQuery.ts create mode 100644 playground/typescript-jsx-router/src/assets/base.css create mode 100644 playground/typescript-jsx-router/src/assets/logo.svg create mode 100644 playground/typescript-jsx-router/src/components/ColorSchemeSwitch.vue create mode 100644 playground/typescript-jsx-router/src/components/IntroductionItem.vue create mode 100644 playground/typescript-jsx-router/src/components/icons/Community.vue create mode 100644 playground/typescript-jsx-router/src/components/icons/Documentation.vue create mode 100644 playground/typescript-jsx-router/src/components/icons/Ecosystem.vue create mode 100644 playground/typescript-jsx-router/src/components/icons/Moon.vue create mode 100644 playground/typescript-jsx-router/src/components/icons/Sun.vue create mode 100644 playground/typescript-jsx-router/src/components/icons/Support.vue create mode 100644 playground/typescript-jsx-router/src/components/icons/Tooling.vue create mode 100644 playground/typescript-jsx-router/src/composables/useColorScheme.ts create mode 100644 playground/typescript-jsx-router/src/composables/useMediaQuery.ts diff --git a/playground/default/src/App.vue b/playground/default/src/App.vue index 64c42595..ab188d52 100644 --- a/playground/default/src/App.vue +++ b/playground/default/src/App.vue @@ -113,18 +113,6 @@ header { line-height: 1.5; } -.color-scheme-switcher { - position: absolute; - left: 0; - top: 20px; - - border: none; - background: transparent; - - color: var(--color-text); - cursor: pointer; -} - .logo { display: block; margin: 0 auto 2rem; @@ -137,8 +125,10 @@ a, transition: 0.4s; } -a:hover { - background-color: hsla(160, 100%, 37%, 0.2); +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } } @media (min-width: 1024px) { @@ -147,6 +137,12 @@ a:hover { place-items: center; } + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } + header { display: flex; place-items: center; @@ -162,26 +158,5 @@ a:hover { .logo { margin: 0 2rem 0 0; } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } - - .router-links { - margin-top: 1rem; - text-align: left; - } - - .router-links a { - padding: 0 0.5rem 0 0; - background-color: transparent; - } - - .router-links a + a { - border-left: 0; - margin-left: 0.2rem; - } } diff --git a/playground/default/src/assets/base.css b/playground/default/src/assets/base.css index e81bad15..6198c024 100644 --- a/playground/default/src/assets/base.css +++ b/playground/default/src/assets/base.css @@ -31,7 +31,7 @@ --color-border-hover: var(--vt-c-divider-light-1); --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-2); + --color-text: var(--vt-c-text-light-1); --section-gap: 160px; } diff --git a/playground/default/src/components/ColorSchemeSwitch.vue b/playground/default/src/components/ColorSchemeSwitch.vue index a4007efe..8e5bb4e2 100644 --- a/playground/default/src/components/ColorSchemeSwitch.vue +++ b/playground/default/src/components/ColorSchemeSwitch.vue @@ -130,7 +130,7 @@ watchEffect(() => { } .color-scheme-switch-wrapper .text { - font-size: 1.3em; + font-size: 1.2rem; font-weight: normal; } } diff --git a/playground/default/src/components/HelloWorld.vue b/playground/default/src/components/HelloWorld.vue index 26672db0..aa16fa1f 100644 --- a/playground/default/src/components/HelloWorld.vue +++ b/playground/default/src/components/HelloWorld.vue @@ -26,7 +26,7 @@ h1 { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; } .greetings h1, diff --git a/playground/default/src/components/IntroductionItem.vue b/playground/default/src/components/IntroductionItem.vue index 58965058..ba0def33 100644 --- a/playground/default/src/components/IntroductionItem.vue +++ b/playground/default/src/components/IntroductionItem.vue @@ -34,7 +34,8 @@ i { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; + font-weight: 500; margin-bottom: 0.4rem; color: var(--color-heading); } diff --git a/playground/jsx-router-vuex-with-tests/cypress/integration/example.spec.js b/playground/jsx-router-vuex-with-tests/cypress/integration/example.spec.js index ec952ec4..13a2922b 100644 --- a/playground/jsx-router-vuex-with-tests/cypress/integration/example.spec.js +++ b/playground/jsx-router-vuex-with-tests/cypress/integration/example.spec.js @@ -3,7 +3,7 @@ describe('My First Test', () => { it('visits the app root url', () => { cy.visit('/') - cy.contains('h1', 'Hello Vue 3 + Vite') + cy.contains('h1', 'You did it!') }) it('navigates to the about page', () => { diff --git a/playground/jsx-router-vuex-with-tests/src/App.vue b/playground/jsx-router-vuex-with-tests/src/App.vue index 6a65bcc1..523cdb78 100644 --- a/playground/jsx-router-vuex-with-tests/src/App.vue +++ b/playground/jsx-router-vuex-with-tests/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/jsx-router-vuex-with-tests/src/assets/base.css b/playground/jsx-router-vuex-with-tests/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/jsx-router-vuex-with-tests/src/assets/logo.svg b/playground/jsx-router-vuex-with-tests/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/jsx-router-vuex-with-tests/src/components/ColorSchemeSwitch.vue b/playground/jsx-router-vuex-with-tests/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..8e5bb4e2 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/jsx-router-vuex-with-tests/src/components/HelloWorld.vue b/playground/jsx-router-vuex-with-tests/src/components/HelloWorld.vue index 51f81a8f..aa16fa1f 100644 --- a/playground/jsx-router-vuex-with-tests/src/components/HelloWorld.vue +++ b/playground/jsx-router-vuex-with-tests/src/components/HelloWorld.vue @@ -1,57 +1,44 @@ - - + + diff --git a/playground/jsx-router-vuex-with-tests/src/components/IntroductionItem.vue b/playground/jsx-router-vuex-with-tests/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/jsx-router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.js b/playground/jsx-router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.js new file mode 100644 index 00000000..3842adf2 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.js @@ -0,0 +1,34 @@ +import { mount } from '@cypress/vue' + +import ColorSchemeSwitch from '../ColorSchemeSwitch.vue' + +describe('ColorSchemeSwitch', () => { + beforeEach(() => { + cy.stub(window, 'matchMedia') + .withArgs('(prefers-color-scheme: light)') + .returns({ + matches: false, + addEventListener: () => {}, + removeEventListener: () => {}, + }) + .withArgs('(prefers-color-scheme: dark)') + .returns({ + matches: true, + addEventListener: () => {}, + removeEventListener: () => {}, + }) + }) + + it('use the preferred color scheme by default', () => { + mount(ColorSchemeSwitch) + + cy.get('body').should('have.attr', 'data-color-scheme', 'dark') + }) + + it('toggles the color scheme affter user clicks toggle', () => { + mount(ColorSchemeSwitch) + + cy.get('.color-scheme-switch').click() + cy.get('body').should('have.attr', 'data-color-scheme', 'light') + }) +}) diff --git a/playground/jsx-router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.js b/playground/jsx-router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.js index 087c9561..a69f3a9d 100644 --- a/playground/jsx-router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.js +++ b/playground/jsx-router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.js @@ -10,13 +10,4 @@ describe('HelloWorld', () => { mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) cy.get('h1').should('contain', 'Hello Cypress') }) - - it('adds 1 when clicking the plus button', () => { - mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) - - cy.get('button') - .should('contain', '0') - .click() - .should('contain', '1') - }) }) diff --git a/playground/jsx-router-vuex-with-tests/src/components/icons/Community.vue b/playground/jsx-router-vuex-with-tests/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router-vuex-with-tests/src/components/icons/Documentation.vue b/playground/jsx-router-vuex-with-tests/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router-vuex-with-tests/src/components/icons/Ecosystem.vue b/playground/jsx-router-vuex-with-tests/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router-vuex-with-tests/src/components/icons/Moon.vue b/playground/jsx-router-vuex-with-tests/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/jsx-router-vuex-with-tests/src/components/icons/Sun.vue b/playground/jsx-router-vuex-with-tests/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/jsx-router-vuex-with-tests/src/components/icons/Support.vue b/playground/jsx-router-vuex-with-tests/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router-vuex-with-tests/src/components/icons/Tooling.vue b/playground/jsx-router-vuex-with-tests/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/jsx-router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.js b/playground/jsx-router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.js new file mode 100644 index 00000000..a7a5d024 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.js @@ -0,0 +1,33 @@ +import { defineComponent, h, createVNode } from 'vue' +import { mount } from '@cypress/vue' + +import useMediaQuery from '../useMediaQuery' + +const Wrapper = defineComponent({ + props: { + query: { + type: String, + required: true + } + }, + setup(props) { + const matches = useMediaQuery(props.query) + return () => h('div', { id: 'result' }, matches.value.toString() ) + } +}) + +describe('useMediaQuery', () => { + it('should correctly reflect the match result of a media query', () => { + mount(Wrapper, { + props: { + query: '(min-width: 800px)' + } + }) + + cy.viewport(1000, 660) + cy.get('#result').should('include.text', 'true') + + cy.viewport(660, 660) + cy.get('#result').should('include.text', 'false') + }) +}) diff --git a/playground/jsx-router-vuex-with-tests/src/composables/useColorScheme.js b/playground/jsx-router-vuex-with-tests/src/composables/useColorScheme.js new file mode 100644 index 00000000..be111aff --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/composables/useColorScheme.js @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/jsx-router-vuex-with-tests/src/composables/useMediaQuery.js b/playground/jsx-router-vuex-with-tests/src/composables/useMediaQuery.js new file mode 100644 index 00000000..bf288056 --- /dev/null +++ b/playground/jsx-router-vuex-with-tests/src/composables/useMediaQuery.js @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event) => { + matches.value = event.matches + } + + // Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/jsx-router-vuex-with-tests/src/views/About.vue b/playground/jsx-router-vuex-with-tests/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/jsx-router-vuex-with-tests/src/views/About.vue +++ b/playground/jsx-router-vuex-with-tests/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/jsx-router-vuex-with-tests/src/views/Home.vue b/playground/jsx-router-vuex-with-tests/src/views/Home.vue index d74dda2c..d91fa611 100644 --- a/playground/jsx-router-vuex-with-tests/src/views/Home.vue +++ b/playground/jsx-router-vuex-with-tests/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/jsx-router-vuex/src/App.vue b/playground/jsx-router-vuex/src/App.vue index 6a65bcc1..523cdb78 100644 --- a/playground/jsx-router-vuex/src/App.vue +++ b/playground/jsx-router-vuex/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/jsx-router-vuex/src/assets/base.css b/playground/jsx-router-vuex/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/jsx-router-vuex/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/jsx-router-vuex/src/assets/logo.svg b/playground/jsx-router-vuex/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/jsx-router-vuex/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/jsx-router-vuex/src/components/ColorSchemeSwitch.vue b/playground/jsx-router-vuex/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..8e5bb4e2 --- /dev/null +++ b/playground/jsx-router-vuex/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/jsx-router-vuex/src/components/HelloWorld.vue b/playground/jsx-router-vuex/src/components/HelloWorld.vue index 51f81a8f..aa16fa1f 100644 --- a/playground/jsx-router-vuex/src/components/HelloWorld.vue +++ b/playground/jsx-router-vuex/src/components/HelloWorld.vue @@ -1,57 +1,44 @@ - - + + diff --git a/playground/jsx-router-vuex/src/components/IntroductionItem.vue b/playground/jsx-router-vuex/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/jsx-router-vuex/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/jsx-router-vuex/src/components/icons/Community.vue b/playground/jsx-router-vuex/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/jsx-router-vuex/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router-vuex/src/components/icons/Documentation.vue b/playground/jsx-router-vuex/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/jsx-router-vuex/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router-vuex/src/components/icons/Ecosystem.vue b/playground/jsx-router-vuex/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/jsx-router-vuex/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router-vuex/src/components/icons/Moon.vue b/playground/jsx-router-vuex/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/jsx-router-vuex/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/jsx-router-vuex/src/components/icons/Sun.vue b/playground/jsx-router-vuex/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/jsx-router-vuex/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/jsx-router-vuex/src/components/icons/Support.vue b/playground/jsx-router-vuex/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/jsx-router-vuex/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router-vuex/src/components/icons/Tooling.vue b/playground/jsx-router-vuex/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/jsx-router-vuex/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/jsx-router-vuex/src/composables/useColorScheme.js b/playground/jsx-router-vuex/src/composables/useColorScheme.js new file mode 100644 index 00000000..be111aff --- /dev/null +++ b/playground/jsx-router-vuex/src/composables/useColorScheme.js @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/jsx-router-vuex/src/composables/useMediaQuery.js b/playground/jsx-router-vuex/src/composables/useMediaQuery.js new file mode 100644 index 00000000..bf288056 --- /dev/null +++ b/playground/jsx-router-vuex/src/composables/useMediaQuery.js @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event) => { + matches.value = event.matches + } + + // Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/jsx-router-vuex/src/views/About.vue b/playground/jsx-router-vuex/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/jsx-router-vuex/src/views/About.vue +++ b/playground/jsx-router-vuex/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/jsx-router-vuex/src/views/Home.vue b/playground/jsx-router-vuex/src/views/Home.vue index d74dda2c..d91fa611 100644 --- a/playground/jsx-router-vuex/src/views/Home.vue +++ b/playground/jsx-router-vuex/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/jsx-router/src/App.vue b/playground/jsx-router/src/App.vue index 6a65bcc1..523cdb78 100644 --- a/playground/jsx-router/src/App.vue +++ b/playground/jsx-router/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/jsx-router/src/assets/base.css b/playground/jsx-router/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/jsx-router/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/jsx-router/src/assets/logo.svg b/playground/jsx-router/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/jsx-router/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/jsx-router/src/components/ColorSchemeSwitch.vue b/playground/jsx-router/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..8e5bb4e2 --- /dev/null +++ b/playground/jsx-router/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/jsx-router/src/components/HelloWorld.vue b/playground/jsx-router/src/components/HelloWorld.vue index 51f81a8f..aa16fa1f 100644 --- a/playground/jsx-router/src/components/HelloWorld.vue +++ b/playground/jsx-router/src/components/HelloWorld.vue @@ -1,57 +1,44 @@ - - + + diff --git a/playground/jsx-router/src/components/IntroductionItem.vue b/playground/jsx-router/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/jsx-router/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/jsx-router/src/components/icons/Community.vue b/playground/jsx-router/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/jsx-router/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router/src/components/icons/Documentation.vue b/playground/jsx-router/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/jsx-router/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router/src/components/icons/Ecosystem.vue b/playground/jsx-router/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/jsx-router/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router/src/components/icons/Moon.vue b/playground/jsx-router/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/jsx-router/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/jsx-router/src/components/icons/Sun.vue b/playground/jsx-router/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/jsx-router/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/jsx-router/src/components/icons/Support.vue b/playground/jsx-router/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/jsx-router/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/jsx-router/src/components/icons/Tooling.vue b/playground/jsx-router/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/jsx-router/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/jsx-router/src/composables/useColorScheme.js b/playground/jsx-router/src/composables/useColorScheme.js new file mode 100644 index 00000000..be111aff --- /dev/null +++ b/playground/jsx-router/src/composables/useColorScheme.js @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/jsx-router/src/composables/useMediaQuery.js b/playground/jsx-router/src/composables/useMediaQuery.js new file mode 100644 index 00000000..bf288056 --- /dev/null +++ b/playground/jsx-router/src/composables/useMediaQuery.js @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event) => { + matches.value = event.matches + } + + // Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/jsx-router/src/views/About.vue b/playground/jsx-router/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/jsx-router/src/views/About.vue +++ b/playground/jsx-router/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/jsx-router/src/views/Home.vue b/playground/jsx-router/src/views/Home.vue index d74dda2c..d91fa611 100644 --- a/playground/jsx-router/src/views/Home.vue +++ b/playground/jsx-router/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/jsx/src/App.vue b/playground/jsx/src/App.vue index 64c42595..ab188d52 100644 --- a/playground/jsx/src/App.vue +++ b/playground/jsx/src/App.vue @@ -113,18 +113,6 @@ header { line-height: 1.5; } -.color-scheme-switcher { - position: absolute; - left: 0; - top: 20px; - - border: none; - background: transparent; - - color: var(--color-text); - cursor: pointer; -} - .logo { display: block; margin: 0 auto 2rem; @@ -137,8 +125,10 @@ a, transition: 0.4s; } -a:hover { - background-color: hsla(160, 100%, 37%, 0.2); +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } } @media (min-width: 1024px) { @@ -147,6 +137,12 @@ a:hover { place-items: center; } + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } + header { display: flex; place-items: center; @@ -162,26 +158,5 @@ a:hover { .logo { margin: 0 2rem 0 0; } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } - - .router-links { - margin-top: 1rem; - text-align: left; - } - - .router-links a { - padding: 0 0.5rem 0 0; - background-color: transparent; - } - - .router-links a + a { - border-left: 0; - margin-left: 0.2rem; - } } diff --git a/playground/jsx/src/assets/base.css b/playground/jsx/src/assets/base.css index e81bad15..6198c024 100644 --- a/playground/jsx/src/assets/base.css +++ b/playground/jsx/src/assets/base.css @@ -31,7 +31,7 @@ --color-border-hover: var(--vt-c-divider-light-1); --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-2); + --color-text: var(--vt-c-text-light-1); --section-gap: 160px; } diff --git a/playground/jsx/src/components/ColorSchemeSwitch.vue b/playground/jsx/src/components/ColorSchemeSwitch.vue index a4007efe..8e5bb4e2 100644 --- a/playground/jsx/src/components/ColorSchemeSwitch.vue +++ b/playground/jsx/src/components/ColorSchemeSwitch.vue @@ -130,7 +130,7 @@ watchEffect(() => { } .color-scheme-switch-wrapper .text { - font-size: 1.3em; + font-size: 1.2rem; font-weight: normal; } } diff --git a/playground/jsx/src/components/HelloWorld.vue b/playground/jsx/src/components/HelloWorld.vue index 26672db0..aa16fa1f 100644 --- a/playground/jsx/src/components/HelloWorld.vue +++ b/playground/jsx/src/components/HelloWorld.vue @@ -26,7 +26,7 @@ h1 { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; } .greetings h1, diff --git a/playground/jsx/src/components/IntroductionItem.vue b/playground/jsx/src/components/IntroductionItem.vue index 58965058..ba0def33 100644 --- a/playground/jsx/src/components/IntroductionItem.vue +++ b/playground/jsx/src/components/IntroductionItem.vue @@ -34,7 +34,8 @@ i { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; + font-weight: 500; margin-bottom: 0.4rem; color: var(--color-heading); } diff --git a/playground/router-vuex-with-tests/cypress/integration/example.spec.js b/playground/router-vuex-with-tests/cypress/integration/example.spec.js index ec952ec4..13a2922b 100644 --- a/playground/router-vuex-with-tests/cypress/integration/example.spec.js +++ b/playground/router-vuex-with-tests/cypress/integration/example.spec.js @@ -3,7 +3,7 @@ describe('My First Test', () => { it('visits the app root url', () => { cy.visit('/') - cy.contains('h1', 'Hello Vue 3 + Vite') + cy.contains('h1', 'You did it!') }) it('navigates to the about page', () => { diff --git a/playground/router-vuex-with-tests/src/App.vue b/playground/router-vuex-with-tests/src/App.vue index 6a65bcc1..523cdb78 100644 --- a/playground/router-vuex-with-tests/src/App.vue +++ b/playground/router-vuex-with-tests/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/router-vuex-with-tests/src/assets/base.css b/playground/router-vuex-with-tests/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/router-vuex-with-tests/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/router-vuex-with-tests/src/assets/logo.svg b/playground/router-vuex-with-tests/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/router-vuex-with-tests/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/router-vuex-with-tests/src/components/ColorSchemeSwitch.vue b/playground/router-vuex-with-tests/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..8e5bb4e2 --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/router-vuex-with-tests/src/components/HelloWorld.vue b/playground/router-vuex-with-tests/src/components/HelloWorld.vue index 51f81a8f..aa16fa1f 100644 --- a/playground/router-vuex-with-tests/src/components/HelloWorld.vue +++ b/playground/router-vuex-with-tests/src/components/HelloWorld.vue @@ -1,57 +1,44 @@ - - + + diff --git a/playground/router-vuex-with-tests/src/components/IntroductionItem.vue b/playground/router-vuex-with-tests/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.js b/playground/router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.js new file mode 100644 index 00000000..3842adf2 --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.js @@ -0,0 +1,34 @@ +import { mount } from '@cypress/vue' + +import ColorSchemeSwitch from '../ColorSchemeSwitch.vue' + +describe('ColorSchemeSwitch', () => { + beforeEach(() => { + cy.stub(window, 'matchMedia') + .withArgs('(prefers-color-scheme: light)') + .returns({ + matches: false, + addEventListener: () => {}, + removeEventListener: () => {}, + }) + .withArgs('(prefers-color-scheme: dark)') + .returns({ + matches: true, + addEventListener: () => {}, + removeEventListener: () => {}, + }) + }) + + it('use the preferred color scheme by default', () => { + mount(ColorSchemeSwitch) + + cy.get('body').should('have.attr', 'data-color-scheme', 'dark') + }) + + it('toggles the color scheme affter user clicks toggle', () => { + mount(ColorSchemeSwitch) + + cy.get('.color-scheme-switch').click() + cy.get('body').should('have.attr', 'data-color-scheme', 'light') + }) +}) diff --git a/playground/router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.js b/playground/router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.js index 087c9561..a69f3a9d 100644 --- a/playground/router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.js +++ b/playground/router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.js @@ -10,13 +10,4 @@ describe('HelloWorld', () => { mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) cy.get('h1').should('contain', 'Hello Cypress') }) - - it('adds 1 when clicking the plus button', () => { - mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) - - cy.get('button') - .should('contain', '0') - .click() - .should('contain', '1') - }) }) diff --git a/playground/router-vuex-with-tests/src/components/icons/Community.vue b/playground/router-vuex-with-tests/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router-vuex-with-tests/src/components/icons/Documentation.vue b/playground/router-vuex-with-tests/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router-vuex-with-tests/src/components/icons/Ecosystem.vue b/playground/router-vuex-with-tests/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router-vuex-with-tests/src/components/icons/Moon.vue b/playground/router-vuex-with-tests/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/router-vuex-with-tests/src/components/icons/Sun.vue b/playground/router-vuex-with-tests/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/router-vuex-with-tests/src/components/icons/Support.vue b/playground/router-vuex-with-tests/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router-vuex-with-tests/src/components/icons/Tooling.vue b/playground/router-vuex-with-tests/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/router-vuex-with-tests/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.js b/playground/router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.js new file mode 100644 index 00000000..a7a5d024 --- /dev/null +++ b/playground/router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.js @@ -0,0 +1,33 @@ +import { defineComponent, h, createVNode } from 'vue' +import { mount } from '@cypress/vue' + +import useMediaQuery from '../useMediaQuery' + +const Wrapper = defineComponent({ + props: { + query: { + type: String, + required: true + } + }, + setup(props) { + const matches = useMediaQuery(props.query) + return () => h('div', { id: 'result' }, matches.value.toString() ) + } +}) + +describe('useMediaQuery', () => { + it('should correctly reflect the match result of a media query', () => { + mount(Wrapper, { + props: { + query: '(min-width: 800px)' + } + }) + + cy.viewport(1000, 660) + cy.get('#result').should('include.text', 'true') + + cy.viewport(660, 660) + cy.get('#result').should('include.text', 'false') + }) +}) diff --git a/playground/router-vuex-with-tests/src/composables/useColorScheme.js b/playground/router-vuex-with-tests/src/composables/useColorScheme.js new file mode 100644 index 00000000..be111aff --- /dev/null +++ b/playground/router-vuex-with-tests/src/composables/useColorScheme.js @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/router-vuex-with-tests/src/composables/useMediaQuery.js b/playground/router-vuex-with-tests/src/composables/useMediaQuery.js new file mode 100644 index 00000000..bf288056 --- /dev/null +++ b/playground/router-vuex-with-tests/src/composables/useMediaQuery.js @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event) => { + matches.value = event.matches + } + + // Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/router-vuex-with-tests/src/views/About.vue b/playground/router-vuex-with-tests/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/router-vuex-with-tests/src/views/About.vue +++ b/playground/router-vuex-with-tests/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/router-vuex-with-tests/src/views/Home.vue b/playground/router-vuex-with-tests/src/views/Home.vue index d74dda2c..d91fa611 100644 --- a/playground/router-vuex-with-tests/src/views/Home.vue +++ b/playground/router-vuex-with-tests/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/router-vuex/src/App.vue b/playground/router-vuex/src/App.vue index 6a65bcc1..523cdb78 100644 --- a/playground/router-vuex/src/App.vue +++ b/playground/router-vuex/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/router-vuex/src/assets/base.css b/playground/router-vuex/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/router-vuex/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/router-vuex/src/assets/logo.svg b/playground/router-vuex/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/router-vuex/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/router-vuex/src/components/ColorSchemeSwitch.vue b/playground/router-vuex/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..8e5bb4e2 --- /dev/null +++ b/playground/router-vuex/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/router-vuex/src/components/HelloWorld.vue b/playground/router-vuex/src/components/HelloWorld.vue index 51f81a8f..aa16fa1f 100644 --- a/playground/router-vuex/src/components/HelloWorld.vue +++ b/playground/router-vuex/src/components/HelloWorld.vue @@ -1,57 +1,44 @@ - - + + diff --git a/playground/router-vuex/src/components/IntroductionItem.vue b/playground/router-vuex/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/router-vuex/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/router-vuex/src/components/icons/Community.vue b/playground/router-vuex/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/router-vuex/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router-vuex/src/components/icons/Documentation.vue b/playground/router-vuex/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/router-vuex/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router-vuex/src/components/icons/Ecosystem.vue b/playground/router-vuex/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/router-vuex/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router-vuex/src/components/icons/Moon.vue b/playground/router-vuex/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/router-vuex/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/router-vuex/src/components/icons/Sun.vue b/playground/router-vuex/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/router-vuex/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/router-vuex/src/components/icons/Support.vue b/playground/router-vuex/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/router-vuex/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router-vuex/src/components/icons/Tooling.vue b/playground/router-vuex/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/router-vuex/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/router-vuex/src/composables/useColorScheme.js b/playground/router-vuex/src/composables/useColorScheme.js new file mode 100644 index 00000000..be111aff --- /dev/null +++ b/playground/router-vuex/src/composables/useColorScheme.js @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/router-vuex/src/composables/useMediaQuery.js b/playground/router-vuex/src/composables/useMediaQuery.js new file mode 100644 index 00000000..bf288056 --- /dev/null +++ b/playground/router-vuex/src/composables/useMediaQuery.js @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event) => { + matches.value = event.matches + } + + // Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/router-vuex/src/views/About.vue b/playground/router-vuex/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/router-vuex/src/views/About.vue +++ b/playground/router-vuex/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/router-vuex/src/views/Home.vue b/playground/router-vuex/src/views/Home.vue index d74dda2c..d91fa611 100644 --- a/playground/router-vuex/src/views/Home.vue +++ b/playground/router-vuex/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/router/src/App.vue b/playground/router/src/App.vue index 6a65bcc1..523cdb78 100644 --- a/playground/router/src/App.vue +++ b/playground/router/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/router/src/assets/base.css b/playground/router/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/router/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/router/src/assets/logo.svg b/playground/router/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/router/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/router/src/components/ColorSchemeSwitch.vue b/playground/router/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..8e5bb4e2 --- /dev/null +++ b/playground/router/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/router/src/components/HelloWorld.vue b/playground/router/src/components/HelloWorld.vue index 51f81a8f..aa16fa1f 100644 --- a/playground/router/src/components/HelloWorld.vue +++ b/playground/router/src/components/HelloWorld.vue @@ -1,57 +1,44 @@ - - + + diff --git a/playground/router/src/components/IntroductionItem.vue b/playground/router/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/router/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/router/src/components/icons/Community.vue b/playground/router/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/router/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router/src/components/icons/Documentation.vue b/playground/router/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/router/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router/src/components/icons/Ecosystem.vue b/playground/router/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/router/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router/src/components/icons/Moon.vue b/playground/router/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/router/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/router/src/components/icons/Sun.vue b/playground/router/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/router/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/router/src/components/icons/Support.vue b/playground/router/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/router/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/router/src/components/icons/Tooling.vue b/playground/router/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/router/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/router/src/composables/useColorScheme.js b/playground/router/src/composables/useColorScheme.js new file mode 100644 index 00000000..be111aff --- /dev/null +++ b/playground/router/src/composables/useColorScheme.js @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/router/src/composables/useMediaQuery.js b/playground/router/src/composables/useMediaQuery.js new file mode 100644 index 00000000..bf288056 --- /dev/null +++ b/playground/router/src/composables/useMediaQuery.js @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event) => { + matches.value = event.matches + } + + // Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/router/src/views/About.vue b/playground/router/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/router/src/views/About.vue +++ b/playground/router/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/router/src/views/Home.vue b/playground/router/src/views/Home.vue index d74dda2c..d91fa611 100644 --- a/playground/router/src/views/Home.vue +++ b/playground/router/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/typescript-jsx-router-vuex-with-tests/cypress/integration/example.spec.ts b/playground/typescript-jsx-router-vuex-with-tests/cypress/integration/example.spec.ts index 3898b0ca..13a2922b 100644 --- a/playground/typescript-jsx-router-vuex-with-tests/cypress/integration/example.spec.ts +++ b/playground/typescript-jsx-router-vuex-with-tests/cypress/integration/example.spec.ts @@ -3,7 +3,7 @@ describe('My First Test', () => { it('visits the app root url', () => { cy.visit('/') - cy.contains('h1', 'Hello Vue 3 + TypeScript + Vite') + cy.contains('h1', 'You did it!') }) it('navigates to the about page', () => { diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/App.vue b/playground/typescript-jsx-router-vuex-with-tests/src/App.vue index 6a65bcc1..ebe7e8c3 100644 --- a/playground/typescript-jsx-router-vuex-with-tests/src/App.vue +++ b/playground/typescript-jsx-router-vuex-with-tests/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/assets/base.css b/playground/typescript-jsx-router-vuex-with-tests/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/assets/logo.svg b/playground/typescript-jsx-router-vuex-with-tests/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/ColorSchemeSwitch.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..894e6bfe --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/HelloWorld.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/HelloWorld.vue index 97b3d3da..c7352017 100644 --- a/playground/typescript-jsx-router-vuex-with-tests/src/components/HelloWorld.vue +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/HelloWorld.vue @@ -1,54 +1,41 @@ - - + + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/IntroductionItem.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.ts b/playground/typescript-jsx-router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.ts new file mode 100644 index 00000000..3842adf2 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/__tests__/ColorSchemeSwitch.spec.ts @@ -0,0 +1,34 @@ +import { mount } from '@cypress/vue' + +import ColorSchemeSwitch from '../ColorSchemeSwitch.vue' + +describe('ColorSchemeSwitch', () => { + beforeEach(() => { + cy.stub(window, 'matchMedia') + .withArgs('(prefers-color-scheme: light)') + .returns({ + matches: false, + addEventListener: () => {}, + removeEventListener: () => {}, + }) + .withArgs('(prefers-color-scheme: dark)') + .returns({ + matches: true, + addEventListener: () => {}, + removeEventListener: () => {}, + }) + }) + + it('use the preferred color scheme by default', () => { + mount(ColorSchemeSwitch) + + cy.get('body').should('have.attr', 'data-color-scheme', 'dark') + }) + + it('toggles the color scheme affter user clicks toggle', () => { + mount(ColorSchemeSwitch) + + cy.get('.color-scheme-switch').click() + cy.get('body').should('have.attr', 'data-color-scheme', 'light') + }) +}) diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.ts b/playground/typescript-jsx-router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.ts index 087c9561..a69f3a9d 100644 --- a/playground/typescript-jsx-router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.ts +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/__tests__/HelloWorld.spec.ts @@ -10,13 +10,4 @@ describe('HelloWorld', () => { mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) cy.get('h1').should('contain', 'Hello Cypress') }) - - it('adds 1 when clicking the plus button', () => { - mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) - - cy.get('button') - .should('contain', '0') - .click() - .should('contain', '1') - }) }) diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Community.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Documentation.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Ecosystem.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Moon.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Sun.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Support.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Tooling.vue b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.ts b/playground/typescript-jsx-router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.ts new file mode 100644 index 00000000..a7a5d024 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/composables/__tests__/useMediaQuery.spec.ts @@ -0,0 +1,33 @@ +import { defineComponent, h, createVNode } from 'vue' +import { mount } from '@cypress/vue' + +import useMediaQuery from '../useMediaQuery' + +const Wrapper = defineComponent({ + props: { + query: { + type: String, + required: true + } + }, + setup(props) { + const matches = useMediaQuery(props.query) + return () => h('div', { id: 'result' }, matches.value.toString() ) + } +}) + +describe('useMediaQuery', () => { + it('should correctly reflect the match result of a media query', () => { + mount(Wrapper, { + props: { + query: '(min-width: 800px)' + } + }) + + cy.viewport(1000, 660) + cy.get('#result').should('include.text', 'true') + + cy.viewport(660, 660) + cy.get('#result').should('include.text', 'false') + }) +}) diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/composables/useColorScheme.ts b/playground/typescript-jsx-router-vuex-with-tests/src/composables/useColorScheme.ts new file mode 100644 index 00000000..6bc17800 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/composables/useColorScheme.ts @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/composables/useMediaQuery.ts b/playground/typescript-jsx-router-vuex-with-tests/src/composables/useMediaQuery.ts new file mode 100644 index 00000000..559b4644 --- /dev/null +++ b/playground/typescript-jsx-router-vuex-with-tests/src/composables/useMediaQuery.ts @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query: string) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event: MediaQueryListEvent) => { + matches.value = event.matches + } + + // @ts-ignore Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // @ts-ignore Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/views/About.vue b/playground/typescript-jsx-router-vuex-with-tests/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/typescript-jsx-router-vuex-with-tests/src/views/About.vue +++ b/playground/typescript-jsx-router-vuex-with-tests/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/typescript-jsx-router-vuex-with-tests/src/views/Home.vue b/playground/typescript-jsx-router-vuex-with-tests/src/views/Home.vue index 4ade1db6..2912eebc 100644 --- a/playground/typescript-jsx-router-vuex-with-tests/src/views/Home.vue +++ b/playground/typescript-jsx-router-vuex-with-tests/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/typescript-jsx-router-vuex/src/App.vue b/playground/typescript-jsx-router-vuex/src/App.vue index 6a65bcc1..ebe7e8c3 100644 --- a/playground/typescript-jsx-router-vuex/src/App.vue +++ b/playground/typescript-jsx-router-vuex/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/typescript-jsx-router-vuex/src/assets/base.css b/playground/typescript-jsx-router-vuex/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/typescript-jsx-router-vuex/src/assets/logo.svg b/playground/typescript-jsx-router-vuex/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/typescript-jsx-router-vuex/src/components/ColorSchemeSwitch.vue b/playground/typescript-jsx-router-vuex/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..894e6bfe --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/typescript-jsx-router-vuex/src/components/HelloWorld.vue b/playground/typescript-jsx-router-vuex/src/components/HelloWorld.vue index 97b3d3da..c7352017 100644 --- a/playground/typescript-jsx-router-vuex/src/components/HelloWorld.vue +++ b/playground/typescript-jsx-router-vuex/src/components/HelloWorld.vue @@ -1,54 +1,41 @@ - - + + diff --git a/playground/typescript-jsx-router-vuex/src/components/IntroductionItem.vue b/playground/typescript-jsx-router-vuex/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/typescript-jsx-router-vuex/src/components/icons/Community.vue b/playground/typescript-jsx-router-vuex/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router-vuex/src/components/icons/Documentation.vue b/playground/typescript-jsx-router-vuex/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router-vuex/src/components/icons/Ecosystem.vue b/playground/typescript-jsx-router-vuex/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router-vuex/src/components/icons/Moon.vue b/playground/typescript-jsx-router-vuex/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/typescript-jsx-router-vuex/src/components/icons/Sun.vue b/playground/typescript-jsx-router-vuex/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/typescript-jsx-router-vuex/src/components/icons/Support.vue b/playground/typescript-jsx-router-vuex/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router-vuex/src/components/icons/Tooling.vue b/playground/typescript-jsx-router-vuex/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/typescript-jsx-router-vuex/src/composables/useColorScheme.ts b/playground/typescript-jsx-router-vuex/src/composables/useColorScheme.ts new file mode 100644 index 00000000..6bc17800 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/composables/useColorScheme.ts @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/typescript-jsx-router-vuex/src/composables/useMediaQuery.ts b/playground/typescript-jsx-router-vuex/src/composables/useMediaQuery.ts new file mode 100644 index 00000000..559b4644 --- /dev/null +++ b/playground/typescript-jsx-router-vuex/src/composables/useMediaQuery.ts @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query: string) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event: MediaQueryListEvent) => { + matches.value = event.matches + } + + // @ts-ignore Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // @ts-ignore Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/typescript-jsx-router-vuex/src/views/About.vue b/playground/typescript-jsx-router-vuex/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/typescript-jsx-router-vuex/src/views/About.vue +++ b/playground/typescript-jsx-router-vuex/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/typescript-jsx-router-vuex/src/views/Home.vue b/playground/typescript-jsx-router-vuex/src/views/Home.vue index 4ade1db6..2912eebc 100644 --- a/playground/typescript-jsx-router-vuex/src/views/Home.vue +++ b/playground/typescript-jsx-router-vuex/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/typescript-jsx-router/src/App.vue b/playground/typescript-jsx-router/src/App.vue index 6a65bcc1..ebe7e8c3 100644 --- a/playground/typescript-jsx-router/src/App.vue +++ b/playground/typescript-jsx-router/src/App.vue @@ -1,30 +1,120 @@ + + diff --git a/playground/typescript-jsx-router/src/assets/base.css b/playground/typescript-jsx-router/src/assets/base.css new file mode 100644 index 00000000..6198c024 --- /dev/null +++ b/playground/typescript-jsx-router/src/assets/base.css @@ -0,0 +1,72 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +[data-color-scheme='dark'] { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/playground/typescript-jsx-router/src/assets/logo.svg b/playground/typescript-jsx-router/src/assets/logo.svg new file mode 100644 index 00000000..bc826fed --- /dev/null +++ b/playground/typescript-jsx-router/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/playground/typescript-jsx-router/src/components/ColorSchemeSwitch.vue b/playground/typescript-jsx-router/src/components/ColorSchemeSwitch.vue new file mode 100644 index 00000000..894e6bfe --- /dev/null +++ b/playground/typescript-jsx-router/src/components/ColorSchemeSwitch.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/playground/typescript-jsx-router/src/components/HelloWorld.vue b/playground/typescript-jsx-router/src/components/HelloWorld.vue index 97b3d3da..c7352017 100644 --- a/playground/typescript-jsx-router/src/components/HelloWorld.vue +++ b/playground/typescript-jsx-router/src/components/HelloWorld.vue @@ -1,54 +1,41 @@ - - + + diff --git a/playground/typescript-jsx-router/src/components/IntroductionItem.vue b/playground/typescript-jsx-router/src/components/IntroductionItem.vue new file mode 100644 index 00000000..ba0def33 --- /dev/null +++ b/playground/typescript-jsx-router/src/components/IntroductionItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/playground/typescript-jsx-router/src/components/icons/Community.vue b/playground/typescript-jsx-router/src/components/icons/Community.vue new file mode 100644 index 00000000..2dc8b055 --- /dev/null +++ b/playground/typescript-jsx-router/src/components/icons/Community.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router/src/components/icons/Documentation.vue b/playground/typescript-jsx-router/src/components/icons/Documentation.vue new file mode 100644 index 00000000..6d4791cf --- /dev/null +++ b/playground/typescript-jsx-router/src/components/icons/Documentation.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router/src/components/icons/Ecosystem.vue b/playground/typescript-jsx-router/src/components/icons/Ecosystem.vue new file mode 100644 index 00000000..c3a4f078 --- /dev/null +++ b/playground/typescript-jsx-router/src/components/icons/Ecosystem.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router/src/components/icons/Moon.vue b/playground/typescript-jsx-router/src/components/icons/Moon.vue new file mode 100644 index 00000000..8e02b917 --- /dev/null +++ b/playground/typescript-jsx-router/src/components/icons/Moon.vue @@ -0,0 +1,18 @@ + + + diff --git a/playground/typescript-jsx-router/src/components/icons/Sun.vue b/playground/typescript-jsx-router/src/components/icons/Sun.vue new file mode 100644 index 00000000..577f8031 --- /dev/null +++ b/playground/typescript-jsx-router/src/components/icons/Sun.vue @@ -0,0 +1,34 @@ + + + diff --git a/playground/typescript-jsx-router/src/components/icons/Support.vue b/playground/typescript-jsx-router/src/components/icons/Support.vue new file mode 100644 index 00000000..7452834d --- /dev/null +++ b/playground/typescript-jsx-router/src/components/icons/Support.vue @@ -0,0 +1,7 @@ + diff --git a/playground/typescript-jsx-router/src/components/icons/Tooling.vue b/playground/typescript-jsx-router/src/components/icons/Tooling.vue new file mode 100644 index 00000000..660598d7 --- /dev/null +++ b/playground/typescript-jsx-router/src/components/icons/Tooling.vue @@ -0,0 +1,19 @@ + + diff --git a/playground/typescript-jsx-router/src/composables/useColorScheme.ts b/playground/typescript-jsx-router/src/composables/useColorScheme.ts new file mode 100644 index 00000000..6bc17800 --- /dev/null +++ b/playground/typescript-jsx-router/src/composables/useColorScheme.ts @@ -0,0 +1,31 @@ +import { ref, computed } from 'vue' +import useMediaQuery from './useMediaQuery' + +// Its value should be consistent when called multiple times. +// So we put it outside the composable function +const isUserToggledDark = ref() + +export default function useColorScheme() { + const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') + + const isDark = computed(() => { + if (typeof isUserToggledDark.value !== 'undefined') { + return isUserToggledDark.value + } else { + return isDefaultDark.value + } + }) + + const toggle = () => { + if (typeof isUserToggledDark.value !== 'undefined') { + isUserToggledDark.value = !isUserToggledDark.value + } else { + isUserToggledDark.value = !isDefaultDark.value + } + } + + return { + toggle, + isDark + } +} diff --git a/playground/typescript-jsx-router/src/composables/useMediaQuery.ts b/playground/typescript-jsx-router/src/composables/useMediaQuery.ts new file mode 100644 index 00000000..559b4644 --- /dev/null +++ b/playground/typescript-jsx-router/src/composables/useMediaQuery.ts @@ -0,0 +1,28 @@ +import { ref, onUnmounted } from 'vue' + +export default function useMediaQuery(query: string) { + const mediaQueryList = window.matchMedia(query) + const matches = ref(mediaQueryList.matches) + + const handler = (event: MediaQueryListEvent) => { + matches.value = event.matches + } + + // @ts-ignore Safari < 14 does not support this + if (mediaQueryList.addEventListener) { + mediaQueryList.addEventListener('change', handler) + } else { + mediaQueryList.addListener(handler) + } + + onUnmounted(() => { + // @ts-ignore Safari < 14 does not support this + if (mediaQueryList.removeEventListener) { + mediaQueryList.removeEventListener('change', handler) + } else { + mediaQueryList.removeListener(handler) + } + }) + + return matches +} diff --git a/playground/typescript-jsx-router/src/views/About.vue b/playground/typescript-jsx-router/src/views/About.vue index 3fa28070..756ad2a1 100644 --- a/playground/typescript-jsx-router/src/views/About.vue +++ b/playground/typescript-jsx-router/src/views/About.vue @@ -3,3 +3,13 @@

This is an about page

+ + diff --git a/playground/typescript-jsx-router/src/views/Home.vue b/playground/typescript-jsx-router/src/views/Home.vue index 4ade1db6..2912eebc 100644 --- a/playground/typescript-jsx-router/src/views/Home.vue +++ b/playground/typescript-jsx-router/src/views/Home.vue @@ -1,19 +1,88 @@ - - - + diff --git a/playground/typescript-jsx/src/App.vue b/playground/typescript-jsx/src/App.vue index 1499f01b..faa0cfa6 100644 --- a/playground/typescript-jsx/src/App.vue +++ b/playground/typescript-jsx/src/App.vue @@ -113,18 +113,6 @@ header { line-height: 1.5; } -.color-scheme-switcher { - position: absolute; - left: 0; - top: 20px; - - border: none; - background: transparent; - - color: var(--color-text); - cursor: pointer; -} - .logo { display: block; margin: 0 auto 2rem; @@ -137,8 +125,10 @@ a, transition: 0.4s; } -a:hover { - background-color: hsla(160, 100%, 37%, 0.2); +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } } @media (min-width: 1024px) { @@ -147,6 +137,12 @@ a:hover { place-items: center; } + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } + header { display: flex; place-items: center; @@ -162,26 +158,5 @@ a:hover { .logo { margin: 0 2rem 0 0; } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } - - .router-links { - margin-top: 1rem; - text-align: left; - } - - .router-links a { - padding: 0 0.5rem 0 0; - background-color: transparent; - } - - .router-links a + a { - border-left: 0; - margin-left: 0.2rem; - } } diff --git a/playground/typescript-jsx/src/assets/base.css b/playground/typescript-jsx/src/assets/base.css index e81bad15..6198c024 100644 --- a/playground/typescript-jsx/src/assets/base.css +++ b/playground/typescript-jsx/src/assets/base.css @@ -31,7 +31,7 @@ --color-border-hover: var(--vt-c-divider-light-1); --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-2); + --color-text: var(--vt-c-text-light-1); --section-gap: 160px; } diff --git a/playground/typescript-jsx/src/components/ColorSchemeSwitch.vue b/playground/typescript-jsx/src/components/ColorSchemeSwitch.vue index a5188c22..cc832566 100644 --- a/playground/typescript-jsx/src/components/ColorSchemeSwitch.vue +++ b/playground/typescript-jsx/src/components/ColorSchemeSwitch.vue @@ -130,7 +130,7 @@ watchEffect(() => { } .color-scheme-switch-wrapper .text { - font-size: 1.3em; + font-size: 1.2rem; font-weight: normal; } } diff --git a/playground/typescript-jsx/src/components/HelloWorld.vue b/playground/typescript-jsx/src/components/HelloWorld.vue index 8a759066..c7352017 100644 --- a/playground/typescript-jsx/src/components/HelloWorld.vue +++ b/playground/typescript-jsx/src/components/HelloWorld.vue @@ -23,7 +23,7 @@ h1 { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; } .greetings h1, diff --git a/playground/typescript-jsx/src/components/IntroductionItem.vue b/playground/typescript-jsx/src/components/IntroductionItem.vue index 58965058..ba0def33 100644 --- a/playground/typescript-jsx/src/components/IntroductionItem.vue +++ b/playground/typescript-jsx/src/components/IntroductionItem.vue @@ -34,7 +34,8 @@ i { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; + font-weight: 500; margin-bottom: 0.4rem; color: var(--color-heading); } diff --git a/playground/typescript/src/App.vue b/playground/typescript/src/App.vue index 1499f01b..faa0cfa6 100644 --- a/playground/typescript/src/App.vue +++ b/playground/typescript/src/App.vue @@ -113,18 +113,6 @@ header { line-height: 1.5; } -.color-scheme-switcher { - position: absolute; - left: 0; - top: 20px; - - border: none; - background: transparent; - - color: var(--color-text); - cursor: pointer; -} - .logo { display: block; margin: 0 auto 2rem; @@ -137,8 +125,10 @@ a, transition: 0.4s; } -a:hover { - background-color: hsla(160, 100%, 37%, 0.2); +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } } @media (min-width: 1024px) { @@ -147,6 +137,12 @@ a:hover { place-items: center; } + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } + header { display: flex; place-items: center; @@ -162,26 +158,5 @@ a:hover { .logo { margin: 0 2rem 0 0; } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } - - .router-links { - margin-top: 1rem; - text-align: left; - } - - .router-links a { - padding: 0 0.5rem 0 0; - background-color: transparent; - } - - .router-links a + a { - border-left: 0; - margin-left: 0.2rem; - } } diff --git a/playground/typescript/src/assets/base.css b/playground/typescript/src/assets/base.css index e81bad15..6198c024 100644 --- a/playground/typescript/src/assets/base.css +++ b/playground/typescript/src/assets/base.css @@ -31,7 +31,7 @@ --color-border-hover: var(--vt-c-divider-light-1); --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-2); + --color-text: var(--vt-c-text-light-1); --section-gap: 160px; } diff --git a/playground/typescript/src/components/ColorSchemeSwitch.vue b/playground/typescript/src/components/ColorSchemeSwitch.vue index a5188c22..cc832566 100644 --- a/playground/typescript/src/components/ColorSchemeSwitch.vue +++ b/playground/typescript/src/components/ColorSchemeSwitch.vue @@ -130,7 +130,7 @@ watchEffect(() => { } .color-scheme-switch-wrapper .text { - font-size: 1.3em; + font-size: 1.2rem; font-weight: normal; } } diff --git a/playground/typescript/src/components/HelloWorld.vue b/playground/typescript/src/components/HelloWorld.vue index 8a759066..c7352017 100644 --- a/playground/typescript/src/components/HelloWorld.vue +++ b/playground/typescript/src/components/HelloWorld.vue @@ -23,7 +23,7 @@ h1 { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; } .greetings h1, diff --git a/playground/typescript/src/components/IntroductionItem.vue b/playground/typescript/src/components/IntroductionItem.vue index 58965058..ba0def33 100644 --- a/playground/typescript/src/components/IntroductionItem.vue +++ b/playground/typescript/src/components/IntroductionItem.vue @@ -34,7 +34,8 @@ i { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; + font-weight: 500; margin-bottom: 0.4rem; color: var(--color-heading); } diff --git a/playground/vuex-with-tests/src/App.vue b/playground/vuex-with-tests/src/App.vue index 64c42595..ab188d52 100644 --- a/playground/vuex-with-tests/src/App.vue +++ b/playground/vuex-with-tests/src/App.vue @@ -113,18 +113,6 @@ header { line-height: 1.5; } -.color-scheme-switcher { - position: absolute; - left: 0; - top: 20px; - - border: none; - background: transparent; - - color: var(--color-text); - cursor: pointer; -} - .logo { display: block; margin: 0 auto 2rem; @@ -137,8 +125,10 @@ a, transition: 0.4s; } -a:hover { - background-color: hsla(160, 100%, 37%, 0.2); +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } } @media (min-width: 1024px) { @@ -147,6 +137,12 @@ a:hover { place-items: center; } + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } + header { display: flex; place-items: center; @@ -162,26 +158,5 @@ a:hover { .logo { margin: 0 2rem 0 0; } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } - - .router-links { - margin-top: 1rem; - text-align: left; - } - - .router-links a { - padding: 0 0.5rem 0 0; - background-color: transparent; - } - - .router-links a + a { - border-left: 0; - margin-left: 0.2rem; - } } diff --git a/playground/vuex-with-tests/src/assets/base.css b/playground/vuex-with-tests/src/assets/base.css index e81bad15..6198c024 100644 --- a/playground/vuex-with-tests/src/assets/base.css +++ b/playground/vuex-with-tests/src/assets/base.css @@ -31,7 +31,7 @@ --color-border-hover: var(--vt-c-divider-light-1); --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-2); + --color-text: var(--vt-c-text-light-1); --section-gap: 160px; } diff --git a/playground/vuex-with-tests/src/components/ColorSchemeSwitch.vue b/playground/vuex-with-tests/src/components/ColorSchemeSwitch.vue index a4007efe..8e5bb4e2 100644 --- a/playground/vuex-with-tests/src/components/ColorSchemeSwitch.vue +++ b/playground/vuex-with-tests/src/components/ColorSchemeSwitch.vue @@ -130,7 +130,7 @@ watchEffect(() => { } .color-scheme-switch-wrapper .text { - font-size: 1.3em; + font-size: 1.2rem; font-weight: normal; } } diff --git a/playground/vuex-with-tests/src/components/HelloWorld.vue b/playground/vuex-with-tests/src/components/HelloWorld.vue index 26672db0..aa16fa1f 100644 --- a/playground/vuex-with-tests/src/components/HelloWorld.vue +++ b/playground/vuex-with-tests/src/components/HelloWorld.vue @@ -26,7 +26,7 @@ h1 { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; } .greetings h1, diff --git a/playground/vuex-with-tests/src/components/IntroductionItem.vue b/playground/vuex-with-tests/src/components/IntroductionItem.vue index 58965058..ba0def33 100644 --- a/playground/vuex-with-tests/src/components/IntroductionItem.vue +++ b/playground/vuex-with-tests/src/components/IntroductionItem.vue @@ -34,7 +34,8 @@ i { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; + font-weight: 500; margin-bottom: 0.4rem; color: var(--color-heading); } diff --git a/playground/vuex/src/App.vue b/playground/vuex/src/App.vue index 64c42595..ab188d52 100644 --- a/playground/vuex/src/App.vue +++ b/playground/vuex/src/App.vue @@ -113,18 +113,6 @@ header { line-height: 1.5; } -.color-scheme-switcher { - position: absolute; - left: 0; - top: 20px; - - border: none; - background: transparent; - - color: var(--color-text); - cursor: pointer; -} - .logo { display: block; margin: 0 auto 2rem; @@ -137,8 +125,10 @@ a, transition: 0.4s; } -a:hover { - background-color: hsla(160, 100%, 37%, 0.2); +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } } @media (min-width: 1024px) { @@ -147,6 +137,12 @@ a:hover { place-items: center; } + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } + header { display: flex; place-items: center; @@ -162,26 +158,5 @@ a:hover { .logo { margin: 0 2rem 0 0; } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } - - .router-links { - margin-top: 1rem; - text-align: left; - } - - .router-links a { - padding: 0 0.5rem 0 0; - background-color: transparent; - } - - .router-links a + a { - border-left: 0; - margin-left: 0.2rem; - } } diff --git a/playground/vuex/src/assets/base.css b/playground/vuex/src/assets/base.css index e81bad15..6198c024 100644 --- a/playground/vuex/src/assets/base.css +++ b/playground/vuex/src/assets/base.css @@ -31,7 +31,7 @@ --color-border-hover: var(--vt-c-divider-light-1); --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-2); + --color-text: var(--vt-c-text-light-1); --section-gap: 160px; } diff --git a/playground/vuex/src/components/ColorSchemeSwitch.vue b/playground/vuex/src/components/ColorSchemeSwitch.vue index a4007efe..8e5bb4e2 100644 --- a/playground/vuex/src/components/ColorSchemeSwitch.vue +++ b/playground/vuex/src/components/ColorSchemeSwitch.vue @@ -130,7 +130,7 @@ watchEffect(() => { } .color-scheme-switch-wrapper .text { - font-size: 1.3em; + font-size: 1.2rem; font-weight: normal; } } diff --git a/playground/vuex/src/components/HelloWorld.vue b/playground/vuex/src/components/HelloWorld.vue index 26672db0..aa16fa1f 100644 --- a/playground/vuex/src/components/HelloWorld.vue +++ b/playground/vuex/src/components/HelloWorld.vue @@ -26,7 +26,7 @@ h1 { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; } .greetings h1, diff --git a/playground/vuex/src/components/IntroductionItem.vue b/playground/vuex/src/components/IntroductionItem.vue index 58965058..ba0def33 100644 --- a/playground/vuex/src/components/IntroductionItem.vue +++ b/playground/vuex/src/components/IntroductionItem.vue @@ -34,7 +34,8 @@ i { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; + font-weight: 500; margin-bottom: 0.4rem; color: var(--color-heading); } diff --git a/playground/with-tests/src/App.vue b/playground/with-tests/src/App.vue index 64c42595..ab188d52 100644 --- a/playground/with-tests/src/App.vue +++ b/playground/with-tests/src/App.vue @@ -113,18 +113,6 @@ header { line-height: 1.5; } -.color-scheme-switcher { - position: absolute; - left: 0; - top: 20px; - - border: none; - background: transparent; - - color: var(--color-text); - cursor: pointer; -} - .logo { display: block; margin: 0 auto 2rem; @@ -137,8 +125,10 @@ a, transition: 0.4s; } -a:hover { - background-color: hsla(160, 100%, 37%, 0.2); +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } } @media (min-width: 1024px) { @@ -147,6 +137,12 @@ a:hover { place-items: center; } + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } + header { display: flex; place-items: center; @@ -162,26 +158,5 @@ a:hover { .logo { margin: 0 2rem 0 0; } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } - - .router-links { - margin-top: 1rem; - text-align: left; - } - - .router-links a { - padding: 0 0.5rem 0 0; - background-color: transparent; - } - - .router-links a + a { - border-left: 0; - margin-left: 0.2rem; - } } diff --git a/playground/with-tests/src/assets/base.css b/playground/with-tests/src/assets/base.css index e81bad15..6198c024 100644 --- a/playground/with-tests/src/assets/base.css +++ b/playground/with-tests/src/assets/base.css @@ -31,7 +31,7 @@ --color-border-hover: var(--vt-c-divider-light-1); --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-2); + --color-text: var(--vt-c-text-light-1); --section-gap: 160px; } diff --git a/playground/with-tests/src/components/ColorSchemeSwitch.vue b/playground/with-tests/src/components/ColorSchemeSwitch.vue index a4007efe..8e5bb4e2 100644 --- a/playground/with-tests/src/components/ColorSchemeSwitch.vue +++ b/playground/with-tests/src/components/ColorSchemeSwitch.vue @@ -130,7 +130,7 @@ watchEffect(() => { } .color-scheme-switch-wrapper .text { - font-size: 1.3em; + font-size: 1.2rem; font-weight: normal; } } diff --git a/playground/with-tests/src/components/HelloWorld.vue b/playground/with-tests/src/components/HelloWorld.vue index 26672db0..aa16fa1f 100644 --- a/playground/with-tests/src/components/HelloWorld.vue +++ b/playground/with-tests/src/components/HelloWorld.vue @@ -26,7 +26,7 @@ h1 { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; } .greetings h1, diff --git a/playground/with-tests/src/components/IntroductionItem.vue b/playground/with-tests/src/components/IntroductionItem.vue index 58965058..ba0def33 100644 --- a/playground/with-tests/src/components/IntroductionItem.vue +++ b/playground/with-tests/src/components/IntroductionItem.vue @@ -34,7 +34,8 @@ i { } h3 { - font-size: 1.3rem; + font-size: 1.2rem; + font-weight: 500; margin-bottom: 0.4rem; color: var(--color-heading); } -- 2.39.5