Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Allow Tailwind v4 for Storefront! (#13240)

Damian Legawiec44d5ca2b1793
diff --git a/storefront/app/views/themes/default/spree/orders/_line_item.html.erb b/storefront/app/views/themes/default/spree/orders/_line_item.html.erb
index 74631830d1..079cda20b1 100644
--- a/storefront/app/views/themes/default/spree/orders/_line_item.html.erb
+++ b/storefront/app/views/themes/default/spree/orders/_line_item.html.erb
@@ -16,7 +16,7 @@
<%= link_to line_item.name, spree_storefront_resource_url(line_item.product), class: 'font-semibold text-text', data: { 'turbo-frame': '_top' } %>
<%= form_for line_item, url: spree.line_item_url(line_item, order_token: line_item.order.token), method: :delete, data: { controller: 'turbo-stream-form' } do |item_form| %>
- <%= button_tag type: :submit, class: 'remove-line-item-button h-100', data: { action: "click->cart#disableCart turbo-stream-form:submit-end->cart#enableCart" } do %>
+ <%= button_tag type: :submit, class: 'remove-line-item-button', data: { action: "click->cart#disableCart turbo-stream-form:submit-end->cart#enableCart" } do %>
<%= render 'spree/shared/icons/cross', size: 16 %>
<% end %>
<% end %>
diff --git a/storefront/app/views/themes/default/spree/page_sections/_breadcrumbs.html.erb b/storefront/app/views/themes/default/spree/page_sections/_breadcrumbs.html.erb
index 914f20a2a8..ae9acfc45d 100644
--- a/storefront/app/views/themes/default/spree/page_sections/_breadcrumbs.html.erb
+++ b/storefront/app/views/themes/default/spree/page_sections/_breadcrumbs.html.erb
@@ -4,7 +4,7 @@
<% if @product.present? %>
<% taxons = product_breadcrumb_taxons(@product) %>
- <ul class="inline-flex space-x-3 text-sm">
+ <ul class="inline-flex gap-3 text-sm">
<% taxons.each_with_index do |taxon, index| %>
<li class="opacity-50"><%= link_to taxon.name, spree.nested_taxons_path(taxon), title: taxon.name %></li>
<div class="breadcrumb-square opacity-50 <%= 'hidden md:block' if index == taxons.length - 1 %>"></div>
diff --git a/storefront/app/views/themes/default/spree/products/_breadcrumbs.html.erb b/storefront/app/views/themes/default/spree/products/_breadcrumbs.html.erb
index ef78c67a9e..8d88766a91 100644
--- a/storefront/app/views/themes/default/spree/products/_breadcrumbs.html.erb
+++ b/storefront/app/views/themes/default/spree/products/_breadcrumbs.html.erb
@@ -1,6 +1,6 @@
<nav id="breadcrumbs" aria-label="breadcrumbs">
<!-- desktop -->
- <ul class="hidden md:inline-flex space-x-3 mb-4 lg:mb-5 text-sm">
+ <ul class="hidden md:inline-flex gap-3 mb-4 lg:mb-5 text-sm">
<% taxons.each_with_index do |taxon, index| %>
<li class="opacity-50"><%= link_to taxon.name, spree.nested_taxons_path(taxon), title: taxon.name %></li>
<div class="breadcrumb-square opacity-50"></div>
diff --git a/storefront/lib/generators/spree/storefront/install/install_generator.rb b/storefront/lib/generators/spree/storefront/install/install_generator.rb
index 6d20466d1e..88257282e9 100644
--- a/storefront/lib/generators/spree/storefront/install/install_generator.rb
+++ b/storefront/lib/generators/spree/storefront/install/install_generator.rb
@@ -15,7 +15,8 @@ module Spree
end
def install
- template 'application.tailwind.css', 'app/assets/stylesheets/application.tailwind.css'
+ empty_directory Rails.root.join('app/assets/tailwind') if Rails.root && !Rails.root.join('app/assets/tailwind').exist?
+ template 'application.css', 'app/assets/tailwind/application.css'
template 'tailwind.config.js', 'config/tailwind.config.js'
if Rails.root && Rails.root.join("Procfile.dev").exist?
diff --git a/storefront/lib/generators/spree/storefront/install/templates/application.tailwind.css b/storefront/lib/generators/spree/storefront/install/templates/application.css
similarity index 91%
rename from storefront/lib/generators/spree/storefront/install/templates/application.tailwind.css
rename to storefront/lib/generators/spree/storefront/install/templates/application.css
index ec71240b1b..b7641f6506 100644
--- a/storefront/lib/generators/spree/storefront/install/templates/application.tailwind.css
+++ b/storefront/lib/generators/spree/storefront/install/templates/application.css
@@ -1,10 +1,107 @@
-@import url("https://esm.sh/[email protected]/swiper-bundle.min.css");
-@import url("https://esm.sh/[email protected]/css/flag-icons.min.css");
+@import url('https://esm.sh/[email protected]/swiper-bundle.min.css');
+@import url('https://esm.sh/[email protected]/css/flag-icons.min.css');
+
+@import 'tailwindcss';
+@plugin "@tailwindcss/typography";
+@plugin "@tailwindcss/forms";
+@plugin "@tailwindcss/aspect-ratio";
+
+/* Link to JS config for content paths */
+@config '../../../config/tailwind.config.js';
+
+/* Tailwind v4 Base Layer - Set default border color */
+@layer base {
+ *, ::after, ::before, ::backdrop, ::file-selector-button {
+ border-color: var(--border-default-color, currentColor);
+ }
+}
+
+/* Tailwind v4 Theme Configuration */
+@theme {
+ /* Custom Colors */
+ --color-primary: var(--primary);
+ --color-accent: var(--accent);
+ --color-neutral: var(--neutral);
+ --color-danger: var(--danger);
+ --color-success: var(--success);
+
+ --color-accent-100: var(--accent-100);
+ --color-neutral-50: var(--neutral-50);
+ --color-neutral-100: var(--neutral-100);
+ --color-neutral-200: var(--neutral-200);
+ --color-neutral-300: var(--neutral-300);
+ --color-neutral-400: var(--neutral-400);
+ --color-neutral-500: var(--neutral-500);
+ --color-neutral-600: var(--neutral-600);
+ --color-neutral-700: var(--neutral-700);
+ --color-neutral-800: var(--neutral-800);
+ --color-neutral-900: var(--neutral-900);
+
+ --color-background: var(--background);
+ --color-section-background: var(--section-background, var(--background));
+ --color-text: var(--text);
+
+ --color-button: rgba(var(--button-rgb), <alpha-value>);
+ --color-button-text: var(--button-text);
+ --color-button-hover: var(--button-hover);
+ --color-button-hover-text: var(--button-hover-text);
+
+ --color-secondary-button: var(--secondary-button);
+ --color-secondary-button-text: var(--secondary-button-text);
+ --color-secondary-button-hover: var(--secondary-button-hover);
+ --color-secondary-button-hover-text: var(--secondary-button-hover-text);
+
+ --color-button-light: var(--button-light);
+ --color-button-light-text: var(--button-light-text);
+ --color-button-light-hover: var(--button-light-hover);
+ --color-button-light-hover-text: var(--button-light-hover-text);
+
+ --color-input: var(--input);
+ --color-input-bg: var(--input-bg);
+ --color-input-text: var(--input-text);
+ --color-input-focus: var(--input-focus);
+ --color-input-focus-bg: var(--input-focus-bg);
+ --color-input-focus-text: var(--input-focus-text);
+
+ /* Letter Spacing */
+ --letter-spacing-widest: 0.07rem;
+
+ /* Animations */
+ --animate-fadeIn: fadeIn 0.5s ease-in-out;
+
+ /* Typography - Prose Colors */
+ --prose-body: var(--text);
+ --prose-headings: var(--text);
+ --prose-bold: var(--text);
+ --prose-links: var(--text);
+ --prose-counters: var(--text);
+ --prose-bullets: var(--text);
+ --prose-lead: var(--text);
+ --prose-hr: var(--border-default-color);
+ --prose-th-borders: var(--border-default-color);
+ --prose-td-borders: var(--border-default-color);
+ --prose-quote-borders: var(--border-default-color);
+ --prose-quotes: var(--text);
+}
+
+/* Define fadeIn keyframes for animation */
+@keyframes fadeIn {
+ from {
+ opacity: 0;
+ }
+ to {
+ opacity: 1;
+ }
+}
-@tailwind base;
-@tailwind components;
-@tailwind utilities;
-@tailwind forms;
+/* Custom Variants */
+
+/* Variant for scrollbar rounded */
+@variant scrollbar {
+ &::-webkit-scrollbar {
+ @slot;
+ }
+}
/*
This is the storefront CSS
@@ -167,10 +264,6 @@ textarea.text-input {
}
.menu-item:focus {
outline: none;
- padding-left: 0.5rem;
- padding-right: 0.5rem;
- margin-left: -0.5rem;
- margin-right: -0.5rem;
border-radius: var(--button-border-radius);
}
@@ -444,9 +537,6 @@ textarea.text-input {
background-color: var(--text);
}
-a:hover {
-}
-
.delivery-list-item:last-child {
border-radius: 0.375rem !important;
}
diff --git a/storefront/lib/generators/spree/storefront/install/templates/tailwind.config.js b/storefront/lib/generators/spree/storefront/install/templates/tailwind.config.js
index af6fec6b3b..8f95b540b2 100644
--- a/storefront/lib/generators/spree/storefront/install/templates/tailwind.config.js
+++ b/storefront/lib/generators/spree/storefront/install/templates/tailwind.config.js
@@ -1,5 +1,5 @@
-const defaultTheme = require('tailwindcss/defaultTheme')
-
+// Tailwind CSS v4 - Minimal config for content paths only
+// Theme configuration has been moved to app/assets/tailwind/application.css
module.exports = {
content: [
'public/*.html',
@@ -13,116 +13,5 @@ module.exports = {
process.env.SPREE_STOREFRONT_PATH + '/app/views/themes/**/*.erb',
process.env.SPREE_STOREFRONT_PATH + '/app/views/spree/**/*.erb',
process.env.SPREE_STOREFRONT_PATH + '/app/views/devise/**/*.erb'
- ],
- plugins: [
- require('@tailwindcss/typography'),
- require('@tailwindcss/forms'),
- require('@tailwindcss/aspect-ratio')
- ],
- variants: {
- scrollbar: ['rounded']
- },
- safelist: [
- 'hidden',
- 'lg:grid',
- 'grid',
- 'text-xs',
- 'text-sm',
- 'text-base',
- 'text-lg',
- 'text-xl',
- 'text-2xl',
- 'text-3xl',
- 'text-4xl',
- 'text-left',
- 'text-right',
- 'text-center',
- 'cursor-wait',
- 'lg:sr-only'
- ],
- theme: {
- extend: {
- fontFamily: {
- body: ['var(--font-body)', ...defaultTheme.fontFamily.sans]
- },
- screens: {
- lg: { raw: '(min-width: 1024px) { &:not(.force-mobile-view *) }' }
- },
- animation: {
- fadeIn: 'fadeIn 0.5s ease-in-out'
- },
- keyframes: {
- fadeIn: {
- '0%': { opacity: 0 },
- '100%': { opacity: 1 }
- }
- },
- colors: {
- primary: 'var(--primary)',
- accent: 'var(--accent)',
- neutral: 'var(--neutral)',
- danger: 'var(--danger)',
- success: 'var(--success)',
-
- 'accent-100': 'var(--accent-100)',
- 'neutral-50': 'var(--neutral-50)',
- 'neutral-100': 'var(--neutral-100)',
- 'neutral-200': 'var(--neutral-200)',
- 'neutral-300': 'var(--neutral-300)',
- 'neutral-400': 'var(--neutral-400)',
- 'neutral-500': 'var(--neutral-500)',
- 'neutral-600': 'var(--neutral-600)',
- 'neutral-700': 'var(--neutral-700)',
- 'neutral-800': 'var(--neutral-800)',
- 'neutral-900': 'var(--neutral-900)',
-
- background: 'var(--background)',
- 'section-background': 'var(--section-background, var(--background))',
- text: 'var(--text)',
-
- button: 'rgba(var(--button-rgb), <alpha-value>)',
- 'button-text': 'var(--button-text)',
- 'button-hover': 'var(--button-hover)',
- 'button-hover-text': 'var(--button-hover-text)',
-
- 'secondary-button': 'var(--secondary-button)',
- 'secondary-button-text': 'var(--secondary-button-text)',
- 'secondary-button-hover': 'var(--secondary-button-hover)',
- 'secondary-button-hover-text': 'var(--secondary-button-hover-text)',
-
- 'button-light': 'var(--button-light)',
- 'button-light-text': 'var(--button-light-text)',
- 'button-light-hover': 'var(--button-light-hover)',
- 'button-light-hover-text': 'var(--button-light-hover-text)',
-
- input: 'var(--input)',
- 'input-bg': 'var(--input-bg)',
- 'input-text': 'var(--input-text)',
- 'input-focus': 'var(--input-focus)',
- 'input-focus-bg': 'var(--input-focus-bg)',
- 'input-focus-text': 'var(--input-focus-text)'
- },
- letterSpacing: {
- widest: '0.07rem'
- },
- typography: {
- DEFAULT: {
- css: {
- '--tw-prose-body': 'var(--text)',
- '--tw-prose-headings': 'var(--text)',
- '--tw-prose-bold': 'var(--text)',
- '--tw-prose-links': 'var(--text)',
- '--tw-prose-counters': 'var(--text)',
- '--tw-prose-bullets': 'var(--text)',
- '--tw-prose-lead': 'var(--text)',
- '--tw-prose-hr': 'var(--border-default-color)',
- '--tw-prose-th-borders': 'var(--border-default-color)',
- '--tw-prose-td-borders': 'var(--border-default-color)',
- '--tw-prose-quote-borders': 'var(--border-default-color)',
- '--tw-prose-quotes': 'var(--text)'
- }
- }
- }
- }
- }
+ ]
}
diff --git a/storefront/spree_storefront.gemspec b/storefront/spree_storefront.gemspec
index df41e80c18..e73fd20ee7 100644
--- a/storefront/spree_storefront.gemspec
+++ b/storefront/spree_storefront.gemspec
@@ -35,6 +35,6 @@ Gem::Specification.new do |s|
s.add_dependency 'mail_form'
s.add_dependency 'stimulus-rails'
s.add_dependency 'tailwindcss-rails'
- s.add_dependency 'tailwindcss-ruby', '~> 3.4.17' # lock at Tailwind v3 for now, https://github.com/rails/tailwindcss-rails?tab=readme-ov-file#choosing-a-specific-version-of-tailwindcss
+ s.add_dependency 'tailwindcss-ruby'
s.add_dependency 'turbo-rails'
end