Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next: Simplified themes plugin API #2548

Merged
merged 8 commits into from
Mar 13, 2024
Merged

Conversation

AdrianGonz97
Copy link
Member

@AdrianGonz97 AdrianGonz97 commented Mar 13, 2024

Linked Issue

Part of #2360

Description

Described here: #2360 (comment)

Follow-up after the discussion in this thread: discord.com/channels/1003691521280856084/1196891462302957608

A change we can do is to expose all of the preset themes in an ESM format (so that they are importable in the user's app) and change the plugin api that registers them.

So rather than doing this (current):

// tailwind.config.js

// user's custom themes
import { myCustomTheme1, myCustomTheme2 } from "./customThemes.js";

/** @type {import('tailwindcss').Config} */
export default {
	// ...
	plugins: [
		skeleton({
			themes: {
				custom: [
					myCustomTheme1,
					myCustomTheme2
				],
				preset: [
					{ name: 'crimson', enhancements: true },
					{ name: 'gold-nouveau', enhancements: true },
					{ name: 'hamlindigo', enhancements: true },
					{ name: 'modern', enhancements: true },
					{ name: 'rocket', enhancements: true },
					{ name: 'sahara', enhancements: true },
					{ name: 'seafoam', enhancements: true },
					{ name: 'skeleton', enhancements: true },
					{ name: 'vintage', enhancements: true },
					{ name: 'wintry', enhancements: true }
				]
			}
		})
	]
};

We can instead unify the api such that custom themes and presets are registered to the same interface (v3):

// tailwind.config.js

// they can all be imported via an import glob
import * as themes from "@skeletonlabs/skeleton/themes";
// or imported individually like so:
import { modern, rocket } from "@skeletonlabs/skeleton/themes";

// user's custom themes
import { myCustomTheme1, myCustomTheme2 } from "./customThemes.js";

/** @type {import('tailwindcss').Config} */
export default {
	// ...
	plugins: [
		skeleton({
			themes: [ 
				myCustomTheme1,
				myCustomTheme2,
				themes.crimson, 
				themes.goldNouveau, 
				themes.hamindigo,
				modern,
				rocket,
				// etc..
			]
		})
	]
};

Copy link

changeset-bot bot commented Mar 13, 2024

⚠️ No Changeset found

Latest commit: da874db

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Mar 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
skeleton-docs ❌ Failed (Inspect) Mar 13, 2024 5:05pm
skeleton-next ❌ Failed (Inspect) Mar 13, 2024 5:05pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
skeleton-themes ⬜️ Ignored (Inspect) Visit Preview Mar 13, 2024 5:05pm

@AdrianGonz97 AdrianGonz97 changed the base branch from dev to next March 13, 2024 16:53
@AdrianGonz97 AdrianGonz97 marked this pull request as ready for review March 13, 2024 17:07
@endigo9740 endigo9740 merged commit e87d703 into next Mar 13, 2024
3 of 4 checks passed
@endigo9740 endigo9740 deleted the feat/tw-plugin-simple-themes branch March 13, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants