Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ecf89c0
chore: add option
Mar 17, 2023
9b0d263
feat: get preference from cookies and set new preference in cookie
Mar 17, 2023
c049126
Merge branch 'master' into feat/sync-cookie
Hossein-Mirazimi Jul 22, 2023
f401f46
chore(deps): update devdependency typescript to v5 (#187)
renovate[bot] Mar 19, 2023
1dea526
fix: wrap injected script with iife (#196)
antfu Jun 21, 2023
e342256
chore: switch to pnpm
antfu Jun 21, 2023
e1c5ff9
chore: fix test
antfu Jun 21, 2023
94eac61
chore(release): 3.3.0
antfu Jun 21, 2023
b32d65c
Merge branch 'feat/sync-cookie' of github.com:Hossein-Mirazimi/color-…
Aug 7, 2023
23cb4b0
feat: add storage option
Aug 11, 2023
8a89267
Merge branch 'master' into feat/sync-cookie
Hossein-Mirazimi Aug 11, 2023
af696e7
fix: check window object for prevent error occured
Aug 11, 2023
9ee19d9
Merge branch 'nuxt-modules:master' into feat/sync-cookie
Hossein-Mirazimi Sep 9, 2023
922e397
chore: update nuxt versions
danielroe Nov 15, 2023
e1cb818
test: ensure routes are prerendered
danielroe Nov 15, 2023
6c1d2ac
chore(deps): update all non-major dependencies (#161)
renovate[bot] Nov 15, 2023
94fa261
chore(deps): update commitlint monorepo to v18 (major) (#213)
renovate[bot] Nov 15, 2023
0055047
chore(deps): update actions/checkout action to v4 (#208)
renovate[bot] Nov 15, 2023
36e83cd
chore(deps): update actions/setup-node action to v4 (#214)
renovate[bot] Nov 15, 2023
2b7633a
fix: initialise helper to empty object when testing
danielroe Nov 15, 2023
07c704f
chore(release): 3.3.1
danielroe Nov 15, 2023
4a5dd55
fix: use `ref` for island color-mode stub and check it is truthy
danielroe Nov 15, 2023
49563d8
chore(release): 3.3.2
danielroe Nov 15, 2023
388cfb5
fix: window reference on build
TheAlexLichter Nov 25, 2023
957d9d4
chore: lint
TheAlexLichter Nov 25, 2023
c8eab90
feat: read cookie from server
TheAlexLichter Nov 25, 2023
427e5bd
Merge remote-tracking branch 'upstream/master' into cookie-storage
TheAlexLichter Nov 25, 2023
ca3ef60
Merge branch 'main' into pr/221
atinux Sep 11, 2024
e7c48a6
chore: lint fix
atinux Sep 11, 2024
30cdf53
Update ci.yml
atinux Sep 11, 2024
a8f0aea
chore: update playground
atinux Sep 12, 2024
46a5a3b
chore: update tests
atinux Sep 12, 2024
bce7cf8
lint fix
atinux Sep 12, 2024
b508787
up
atinux Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,25 @@ on:

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [18, 20]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: checkout
uses: actions/checkout@v4

- name: cache node_modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/pnpm-lock.yaml')) }}

- run: corepack enable

node-version: 20
cache: "pnpm"
- name: Install dependencies
run: pnpm install

- name: Prepare TypeScript environment
run: pnpm run dev:prepare

- name: Lint
run: pnpm run lint

- name: Test
run: pnpm run test

- name: Build project
run: pnpm run prepack

- name: Coverage
uses: codecov/codecov-action@v4
env:
Expand Down
57 changes: 55 additions & 2 deletions playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
<script setup>
useSeoMeta({
title: 'Nuxt Color Mode',
description: 'Demo of using @nuxtjs/color-mode for Nuxt, supporting dark mode and custom colors',
})
</script>

<template>
<NuxtLayout>
<div class="container mx-auto text-center p-14">
<NuxtLogo class="inline-block pb-5" />
<ColorModePicker />
<NuxtPage />
</NuxtLayout>
<p class="p-4 rounded-lg bg-[--bg-secondary] text-[--color-secondary] inline-block">
Demo based on <a href="https://color-mode.nuxtjs.org">@nuxtjs/color-mode</a> module.
</p>
</div>
</template>

<style lang="postcss">
:root {
--color: #243746;
--color-primary: #158876;
--color-secondary: #0e2233;
--bg: #f3f5f4;
--bg-secondary: #fff;
--border-color: #ddd;
}

.dark-mode {
--color: #ebf4f1;
--color-primary: #41b38a;
--color-secondary: #fdf9f3;
--bg: #091a28;
--bg-secondary: #071521;
--border-color: #0d2538;
}
.sepia-mode {
--color: #433422;
--color-secondary: #504231;
--bg: #f1e7d0;
--bg-secondary: #eae0c9;
--border-color: #ded0bf;
}

body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background-color: var(--bg);
color: var(--color);
transition: background-color .3s;
}
a {
color: var(--color-primary);
text-decoration: underline;
}
p {
@apply p-5;
}
</style>
34 changes: 0 additions & 34 deletions playground/assets/main.css

This file was deleted.

37 changes: 25 additions & 12 deletions playground/components/ColorModePicker.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
<script setup>
function iconName(theme) {
if (theme === 'system') return 'i-ph-laptop'
if (theme === 'light') return 'i-ph-sun'
if (theme === 'dark') return 'i-ph-moon'
return 'i-ph-coffee'
}
</script>

<template>
<div>
<ul>
<li
v-for="color of ['system', 'light', 'dark', 'sepia']"
:key="color"
v-for="theme of ['system', 'light', 'dark', 'sepia']"
:key="theme"
:class="{
preferred: !$colorMode.unknown && color === $colorMode.preference,
selected: !$colorMode.unknown && color === $colorMode.value,
preferred: !$colorMode.unknown && theme === $colorMode.preference,
selected: !$colorMode.unknown && theme === $colorMode.value,
}"
>
<component
:is="`icon-${color}`"
@click="$colorMode.preference = color"
<Icon
:name="iconName(theme)"
class="size-6"
@click="$colorMode.preference = theme"
/>
</li>
</ul>
Expand All @@ -20,8 +30,9 @@
placeholder="..."
tag="span"
>
Color mode: <b>{{ $colorMode.preference }}</b>
Preference: <b>{{ $colorMode.preference }}</b>
<span v-if="$colorMode.preference === 'system'">&nbsp;(<i>{{ $colorMode.value }}</i> mode detected)</span>
<span v-if="$colorMode.forced">&nbsp;(<i>{{ $colorMode.value }}</i> forced)</span>
</ColorScheme>
</p>
</div>
Expand All @@ -36,13 +47,15 @@ ul {
ul li {
display: inline-block;
padding: 5px;
margin-right: 10px;
line-height: 0;
}
p {
margin: 0;
padding-top: 5px;
padding-bottom: 20px;
}
.feather {
li {
position: relative;
top: 0px;
cursor: pointer;
Expand All @@ -53,14 +66,14 @@ p {
border-radius: 5px;
transition: all 0.1s ease;
}
.feather:hover {
li:hover {
top: -3px;
}
.preferred .feather {
li.preferred {
border-color: var(--color-primary);
top: -3px;
}
.selected .feather {
li.selected {
color: var(--color-primary);
}
</style>
14 changes: 0 additions & 14 deletions playground/components/IconDark.vue

This file was deleted.

58 changes: 0 additions & 58 deletions playground/components/IconLight.vue

This file was deleted.

29 changes: 0 additions & 29 deletions playground/components/IconSepia.vue

This file was deleted.

31 changes: 0 additions & 31 deletions playground/components/IconSystem.vue

This file was deleted.

34 changes: 0 additions & 34 deletions playground/layouts/default.vue

This file was deleted.

Loading