Skip to content

Commit

Permalink
Merge pull request #42 from josefaidt/next
Browse files Browse the repository at this point in the history
  • Loading branch information
josefaidt committed Jan 22, 2022
2 parents 56420fd + 3d39eac commit 662b86e
Show file tree
Hide file tree
Showing 65 changed files with 5,199 additions and 6,627 deletions.
16 changes: 0 additions & 16 deletions .eslintrc.cjs

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules
*.log
.vscode

lib
/lib

.vercel
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.16.0
16
3 changes: 3 additions & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.changesets
.github
.vscode
46 changes: 46 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributing

## Prerequisites

- Node.js version mentioned in [.nvmrc](./.nvmrc)
- [pnpm](https://pnpm.io/) -- `npm install -g pnpm`

## Development

This guide utilizes the [GitHub CLI](https://cli.github.com/)

1. `gh repo fork josefaidt/svelte-themer`
2. Follow the prompts to clone the fork

```console
? Would you like to clone the fork? Yes
```

3. This will clone the forked repository locally with `origin` and `upstream` remotes, as well as set up local branches tracking existing upstream branches. To proceed with development off the `main` branch, run:

```console
git checkout -b my-new-branch
```

4. Install dependencies with `pnpm install`
5. Run the development servers with `pnpm start`

## Sync Local Branches

```console
git checkout main
git fetch upstream
git pull --strategy-option theirs
```

## Releasing

### Latest

1. `pnpm version --<major|minor|patch>`
2. `pnpm publish`

### Next

1. `pnpm version prerelease --preid next`
2. `pnpm publish --tag next --publish-branch next`
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ Turns into
.theme--light {
--theme-colors-text: var(--theme-light-colors-text);
--theme-colors-background: var(--theme-light-colors-background);
--theme-colors-background-contrast: --var(theme-light-colors-background-contrast);
--theme-colors-background-contrast: --var(
theme-light-colors-background-contrast
);
--theme-colors-primary: var(--theme-light-colors-primary);
--theme-colors-primary_dark: var(--theme-light-colors-primary_dark);
--theme-colors-secondary: var(--theme-light-colors-secondary);
Expand Down Expand Up @@ -191,3 +193,11 @@ Described below is the pattern used for accessing `theme` context to create your
</main>
</ThemeWrapper>
```

## Contributing

Refer to the [contributing guidelines](CONTRIBUTING.md).

## License

[MIT](LICENSE)
8 changes: 0 additions & 8 deletions components/ThemeToggle.test.component.svelte

This file was deleted.

39 changes: 0 additions & 39 deletions components/ThemeToggle.test.js

This file was deleted.

4 changes: 2 additions & 2 deletions components/ThemeWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
themesStore.set(themes)
const [fallback] = Object.keys(themes)
$: if (!Object.keys(themes).includes($currentThemeName))
if (!Object.keys(themes).includes($currentThemeName))
currentThemeName.set(fallback)
$: currentThemeObject.set(themes[$currentThemeName])
Expand Down Expand Up @@ -96,7 +96,7 @@
} else if (saved && themes[saved]) {
currentThemeName.set(saved)
} else {
if (mode === 'auto' && preferredMode) {
if (mode === 'auto' && preferredMode && themes[preferredMode]) {
currentThemeName.set(preferredMode)
} else if (['light', 'dark'].includes(mode) && themes[mode]) {
currentThemeName.set(mode)
Expand Down
111 changes: 0 additions & 111 deletions components/ThemeWrapper.test.js

This file was deleted.

2 changes: 2 additions & 0 deletions components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as ThemeWrapper } from './ThemeWrapper.svelte'
export { default as ThemeToggle } from './ThemeToggle.svelte'
6 changes: 4 additions & 2 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build
.vercel
/node_modules/
/dist/
/.vscode/
.DS_Store
48 changes: 48 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Svelte + Vite

This template should help get you started developing with Svelte in Vite.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).

## Need an official Svelte framework?

Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.

## Technical considerations

**Why use this over SvelteKit?**

- It brings its own routing solution which might not be preferable for some users.
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
`vite dev` and `vite build` wouldn't work in a SvelteKit environment, for example.

This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.

Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.

**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**

Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.

**Why include `.vscode/extensions.json`?**

Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.

**Why enable `checkJs` in the JS template?**

It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration.

**Why is HMR not preserving my local component state?**

HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).

If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.

```js
// store.js
// An extremely simple external store
import { writable } from 'svelte/store'
export default writable(0)
```
34 changes: 5 additions & 29 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>svelte themer</title>

<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="/global.css" />

<meta
name="description"
content="A theming engine for your Svelte apps using CSS Variables, persisted."
/>
<meta name="keywords" content="svelte,theme,themer" />

<meta property="og:url" content="https://svelte-themer.now.sh" />
<meta property="og:title" content="svelte themer" />
<meta
property="og:description"
content="A theming engine for your Svelte apps using CSS Variables, persisted."
/>
<meta property="og:image" content="favicon.png" />

<meta name="twitter:card" content="summary" />
<meta name="twitter:creator" content="@josefaidt" />
<meta name="twitter:title" content="svelte themer" />
<meta
name="twitter:description"
content="A theming engine for your Svelte apps using CSS Variables, persisted."
/>
<meta name="twitter:image" content="favicon.png" />
<title>Svelte Themer - A theming engine for your Svelte apps using CSS Variables, persisted.</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>svelte-themer</title>
</head>
<body>
<script type="module" src="/src/index.js"></script>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
Loading

0 comments on commit 662b86e

Please sign in to comment.