Skip to content

Commit

Permalink
Merge pull request #40 from josefaidt/next
Browse files Browse the repository at this point in the history
  • Loading branch information
josefaidt committed Oct 3, 2021
2 parents e498364 + 08d0f94 commit 08b9db8
Show file tree
Hide file tree
Showing 16 changed files with 2,415 additions and 2,572 deletions.
16 changes: 16 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
extends: ['eslint:recommended'],
plugins: ['svelte3', 'jest'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
},
env: {
browser: true,
es2020: true,
node: true,
'jest/globals': true,
},
}
3 changes: 3 additions & 0 deletions components/ThemeToggle.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import '@testing-library/jest-dom/extend-expect'
import { render, fireEvent, getByTestId } from '@testing-library/svelte'
import { currentThemeName } from '../support/store'
Expand Down
3 changes: 2 additions & 1 deletion components/ThemeWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
import { onMount, afterUpdate, setContext } from 'svelte'
import { presets } from './presets'
import toggle from '../support/toggle'
import createCSS from '../support/createCSS'
import { createCSS } from '../support/css'
import {
currentThemeName,
currentThemeObject,
currentMode,
themes as themesStore,
} from '../support/store'
import isObject from '../support/isObject'
Expand Down
31 changes: 28 additions & 3 deletions components/ThemeWrapper.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import '@testing-library/jest-dom/extend-expect'
import { render } from '@testing-library/svelte'
import ThemeWrapper, {
Expand Down Expand Up @@ -26,7 +29,9 @@ describe(ThemeWrapper.name, () => {
})

afterEach(() => {
document.querySelectorAll('style').forEach(sheet => sheet.cssRules && sheet.remove())
document
.querySelectorAll('style')
.forEach(sheet => sheet.cssRules && sheet.remove())
})

it('should render', () => {
Expand Down Expand Up @@ -61,7 +66,9 @@ describe(ThemeWrapper.name, () => {
})

it('should not use CSS Variables prefix when prefix is null', () => {
const { container } = TestHarness({ prefix: null })
const { container } = TestHarness({
prefix: null,
})
expect(getCSSVar('--colors-text')).toBeTruthy()
})

Expand All @@ -70,6 +77,24 @@ describe(ThemeWrapper.name, () => {
})
})

it('should accept base styles as initial CSS Variables values', () => {
const base = {
colors: {
primary: 'red',
},
}
const themes = {
test: {
colors: {
primary: 'blue',
},
},
}
const results = TestHarness({ base, themes })
expect(getCSSVar('--theme-colors-primary')).not.toEqual('initial')
expect(getCSSVar('--theme-colors-primary')).toEqual('red')
})

describe('server-side context', () => {
const { window } = global
beforeEach(() => {
Expand All @@ -78,7 +103,7 @@ describe(ThemeWrapper.name, () => {
afterAll(() => {
global.window = window
})
it('should not fail to render', () => {
it('should render', () => {
const { component } = TestHarness()
expect(component).toBeTruthy()
})
Expand Down
12 changes: 6 additions & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"serve": "vite preview"
},
"devDependencies": {
"@rollup/plugin-replace": "^2.4.1",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.5",
"autoprefixer": "^10.2.5",
"postcss": "^8.2.8",
"svelte": "^3.35.0",
"@rollup/plugin-replace": "^3.0.0",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.22",
"autoprefixer": "^10.3.4",
"postcss": "^8.3.6",
"svelte": "^3.42.4",
"svelte-themer": "../",
"vite": "^2.1.3"
"vite": "^2.5.6"
}
}
9 changes: 7 additions & 2 deletions docs/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@
<section id="intro">
<header>
<h1>Svelte Themer</h1>
<p>A theming engine for your Svelte apps using CSS Variables, persisted.</p>
<p>
A theming engine for your Svelte apps using CSS Variables,
persisted.
</p>
</header>
<div class="apps">
<a
href="https://github.com/josefaidt/svelte-themer/blob/main/README.md#svelte-themer"
>readme</a>
>
readme
</a>
<a href="https://www.npmjs.com/package/svelte-themer">npm</a>
<a href="https://github.com/josefaidt/svelte-themer">github</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile } from 'fs/promises'
import { resolve } from 'path'
import svelte from '@sveltejs/vite-plugin-svelte'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import replace from '@rollup/plugin-replace'
import autoprefixer from 'autoprefixer'
import { defineConfig } from 'vite'
Expand Down
Loading

1 comment on commit 08b9db8

@vercel
Copy link

@vercel vercel bot commented on 08b9db8 Oct 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.