GithubHelp home page GithubHelp logo

tolking / vuepress-theme-default-prefers-color-scheme Goto Github PK

View Code? Open in Web Editor NEW
50.0 3.0 8.0 872 KB

add prefers-color-scheme for vuepress default theme

Home Page: https://tolking.github.io/vuepress-theme-default-prefers-color-scheme

License: MIT License

JavaScript 0.34% Vue 9.14% Stylus 90.52%
vuepress vuepress-theme documentation prefers-color-scheme light-theme dark-theme

vuepress-theme-default-prefers-color-scheme's Introduction

⚠️ This library is no longer maintained.

It is recommended to use VitePress to build your document, as it supports dark mode by default.

License Latest tag via npm Latest tag via GitHub

vuepress-theme-default-prefers-color-scheme

This plugin adds support for prefers-color-scheme to the Vuepress 1.x default theme.

Live Demo and Documentation

Installation

yarn add vuepress-theme-default-prefers-color-scheme
# or
npm i vuepress-theme-default-prefers-color-scheme

Usage

// .vuepress -> config.js
module.exports = {
  theme: 'default-prefers-color-scheme'
}

Options

overrideTheme (optional)

Force users into a specific theme, ignoring prefers-color-scheme.

Allowed values:

  • 'light' | 'dark': Always use the given theme
  • { light: [beginHours: number, endHours: number], dark: [beginHours: number, endHours: number] }: Control the time of the day when each theme is used

For example:

module.exports = {
  theme: 'default-prefers-color-scheme',
  themeConfig: {
    overrideTheme: 'dark',
    // or
    overrideTheme: { light: [6, 18], dark: [18, 6] },
  }
}

prefersTheme (optional)

Use the given theme when the browser does not support prefers-color-scheme but supports CSS Variables

Allowed values:

  • 'light' | 'dark'

For example:

module.exports = {
  theme: 'default-prefers-color-scheme',
  themeConfig: {
    prefersTheme: 'dark',
  }
}

Theme Config

Styling

Apply simple color overrides to the styling of the default preset in your .vuepress/styles/palette.styl file.

Alternatively, set CSS Variables in your .vuepress/styles/index.styl file.

$accentColor and $accentDarkColor are best changed together

Changelog

This project uses semantic versioning and tracks changes in CHANGELOG.

License

MIT

vuepress-theme-default-prefers-color-scheme's People

Contributors

grandsilence avatar jrappen avatar spawnia avatar tolking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vuepress-theme-default-prefers-color-scheme's Issues

Typo in palette.styl

dark mode colors suggestion

Warning box background colors are too bright;

Screenshot

cap 1

Therefore the "warning" cannot be read.

cap

  1. Make the backgrounds of the alert boxes darker.
  2. The code block line accent color should be a little lighter.

Toggle dark mode

This is a feature request.

Is it planned to add a feature to support toggling the theme? This could also be saved in local storage so the site remebers the user's choice.

v1.1.0 not using preferred scheme in Chrome on Windows

I tried upgrading to version 1.1.0, but found that it did not respect my preferred color scheme, using Chrome on Windows. Changing the <html> tag to contain theme="dark" did work, but the "magic" was gone.

Reverting back to 1.0.9 resolved the issue and it just works again.

Scroll bar

Hi, sorry for bothering.
I just stumbled across your project and included it immediately, really loving it.
However.. I noticed that the scroll bar is being changed by the theme.
The default theme (vuepress 1.8.2) uses the browers vanilla scroll bar.

Can I, somehow change that?
So it becomes clickable. A lot of old folks work at our company.

Thanks for your theme. - junaga

Enabling the theme on vuepress2 gives error on compilation

ERROR in ./node_modules/vuepress-theme-default-prefers-color-scheme/layouts/Layout.vue?vue&type=style&index=0&id=7606814d&lang=stylus (./node_modules/css-loader/dist/cjs.js??clonedRuleSet-24.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-24.use[2]!./node_modules/stylus-loader/dist/cjs.js??clonedRuleSet-24.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./node_modules/vuepress-theme-default-prefers-color-scheme/layouts/Layout.vue?vue&type=style&index=0&id=7606814d&lang=stylus)
Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):                                                                                 SyntaxError: Number, dimension, ratio or identifier is expected                                                                                           at Object.error (/home/avivace/gbdev/gbadev.net/node_modules/css-tree/lib/parser/create.js:240:19)                                                    at Object.parse [as MediaFeature] (/home/avivace/gbdev/gbadev.net/node_modules/css-tree/lib/syntax/node/MediaFeature.js:52:26)              
    at Object.parse [as MediaQuery] (/home/avivace/gbdev/gbadev.net/node_modules/css-tree/lib/syntax/node/MediaQuery.js:40:34)                     
    at Object.parse [as MediaQueryList] (/home/avivace/gbdev/gbadev.net/node_modules/css-tree/lib/syntax/node/MediaQueryList.js:16:32)                    at Object.prelude (/home/avivace/gbdev/gbadev.net/node_modules/css-tree/lib/syntax/atrule/media.js:5:22)                                              at Object.parse [as AtrulePrelude] (/home/avivace/gbdev/gbadev.net/node_modules/css-tree/lib/syntax/node/AtrulePrelude.js:23:50)
    at Object.atrulePrelude (/home/avivace/gbdev/gbadev.net/node_modules/css-tree/lib/syntax/config/parser.js:7:25)                                       at /home/avivace/gbdev/gbadev.net/node_modules/css-tree/lib/parser/create.js:296:39                                                                                                                                                                                                                     ERROR in ./node_modules/vuepress-theme-default-prefers-color-scheme/layouts/Layout.vue?vue&type=script&lang=js (./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./node_modules/vuepress-theme-default-prefers-color-scheme/layouts/Layout.vue?vue&type=script&lang=js) 2:0-59                    Module not found: Error: Can't resolve '@parent-theme/layouts/Layout.vue' in '/home/avivace/gbdev/gbadev.net/node_modules/vuepress-theme-default-prefe
rs-color-scheme/layouts'                                                                                                                    
                                                                                                                                               
webpack compiled with 2 errors

Is this expected?

Workflows

Workflow replacements as discussed in #28.


deploy

name: deploy

on:
  push:
    branches:
      - master
    paths:
      - 'docs/**'

jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:

      # Compare https://github.com/actions/checkout
      - name: Checkout
        uses: actions/checkout@v2
        with:
          persist-credentials: false

      - name: Build docs
        run: |
          yarn install
          vuepress build docs/ --no-cache

      # Compare https://github.com/peaceiris/actions-gh-pages
      - name: Deploy Docs
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./dist
          user_name: 'github-actions[bot]'
          user_email: 'github-actions[bot]@users.noreply.github.com'
          commit_message: 'deploy:'

test

name: test

on:
  push:
    branches:
      - dev
      - next
    paths:
      - 'docs/**'
  pull_request:
    branches:
      - master
      - dev
      - next
    paths:
      - 'docs/**'

jobs:
  test:
    runs-on: ubuntu-18.04
    steps:

      # Compare https://github.com/actions/checkout
      - name: Checkout
        uses: actions/checkout@v2
        with:
          persist-credentials: false

      - name: '[Test] Build docs'
        run: |
          yarn install
          vuepress build docs/ --no-cache

      # don't deploy

Missing variables

Hello @tolking,

could you add some variables (for me) to your theme?

Found these missing while looking at @vuepress/core/lib/client/style/config.styl:

  • $badgeTipColor (and dark variant)
  • $badgeWarningColor (and dark variant)
  • $badgeErrorColor (and dark variant)

Found these missing while testing your theme and looking at styles/palette.styl:

  • $tipColor (and dark variant)
  • $lighten10AccentColor (and dark variant)
  • $lighten10TextColor (and dark variant)
  • $lighten20TextColor (and dark variant)
  • $lighten25TextColor (and dark variant)
  • $lighten35TextColor (and dark variant)
  • $lighten40TextColor (and dark variant)
  • $darken10AccentColor (and dark variant)
  • $darken10BgColor (and dark variant)
  • $darken10BorderColor (and dark variant)

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.