2.3.0 • Published 3 years ago

@fallsimply/themer v2.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@fallsimply/themer

install with npm i -D @fallsimply/themer or yarn add -D @fallsimply/themer

alternative to prefers-color-scheme media queries that allows using themes besides the native theme

sets an attribute on the body element - either light or dark

breaking changes

version 2 uses the document's html element as the root instead of the body element

before / after

before

CSS

main {
	color: black;
	background: white;
}
@media (prefers-color-scheme: dark) {
	main {
		color: white;
		background: black;
	}
}

CSS Variables

:root {
	--link: #00f;
}
@media (prefers-color-scheme: dark) {
	:root[dark] {
		--link: #f0f;
	}
}

after

CSS

main {
	color: black;
	background: white;
}

[dark] main {
	
	color: white;
	background: black;
}

CSS with Variables

:root {
	--link: #00f;
}

:root[dark] {
	--link: #f0f;
}

JS

import Themer from @fallsimply/themer
window.themer = new Themer()

additional themes shim

place in a .d.ts shim file such as shims-themer.d.ts to add additional themes add a union type under themes

import themer from "@fallsimply/themer";

declare module '@fallsimply/themer' {
	interface Options {
		themes: "sepia" | "amoled"
	}
}

declare global {
	interface Window {
		themer: themer
	}
}
}
2.3.0

3 years ago

2.2.1

3 years ago

1.2.0

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago