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

JIT Tailwind (experimental) #5438

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
web: env RUBY_DEBUG_OPEN=true bin/rails server
admin_tailwind: bin/rails solidus_admin:tailwindcss:watch
1 change: 0 additions & 1 deletion admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ A Rails engine that provides an administrative interface to the Solidus ecommerc

## Development

- [Customizing tailwind](docs/customizing_tailwind.md)
- [Customizing view components](docs/customizing_view_components.md)
- [Customizing the main navigation](docs/customizing_main_navigation.md)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/*
* = require solidus_admin/tailwind.css
*/

This file was deleted.

134 changes: 134 additions & 0 deletions admin/app/views/layouts/solidus_admin/_tailwindcss_cdn.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<script src="https://cdn.tailwindcss.com/3.3.3?plugins=typography,aspect-ratio"></script>

<style type="text/tailwindcss">
@layer base {

.body-tiny {
@apply font-sans font-normal text-xs;
}

.body-tiny-bold {
@apply font-sans font-semibold text-xs;
}

.body-small {
@apply font-sans font-normal text-sm;
}

.body-small-bold {
@apply font-sans font-semibold text-sm;
}

.body-text {
@apply font-sans font-normal text-base;
}

.body-text-bold {
@apply font-sans font-semibold text-base;
}

.body-title {
@apply font-sans font-semibold text-xl;
}
}
</style>

<script type="module">
import forms from '@tailwindcss/forms'
import containerQueries from '@tailwindcss/forms'
const {defaultTheme} = tailwind
tailwind.config = {
theme: {
extend: {
aria: {
'current': 'current="true"',
},
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
colors: {
transparent: "transparent",
current: "currentColor",

// Primary palette
'solidus-red': "#ef3023",
black: "#222222",
graphite: "#c7ccc7",
'graphite-light': "#d8dad8",
sand: "#f5f3f0",
white: "#ffffff",

// Secondary palette
yellow: "#fdc071",
orange: "#f68050",
blue: "#2554b1",
moss: "#2d3925",
forest: "#096756",
midnight: "#163449",
pink: "#f6d7e2",
plum: "#3a0e31",
sky: "#cbdff1",
seafoam: "#c1e0de",
dune: "#e6bf9b",
'full-black': "#000000",

// Extra colors (not part of the original palette)
'papaya-whip': "#f9e3d9",

// UI Red
red: {
100: "#f8d6d3",
200: "#f1ada7",
300: "#ea8980",
400: "#e36054",
500: "#dc3728",
600: "#b12c20",
700: "#862219",
800: "#561610",
900: "#2b0b08",
},

// Grayscale
gray: {
15: "#fafafa",
25: "#f5f5f5",
50: "#f0f0f0",
100: "#dedede",
200: "#cfcfcf",
300: "#bababa",
400: "#a3a3a3",
500: "#737373",
600: "#616161",
700: "#4a4a4a",
800: "#333333",
},
},
borderRadius: {
sm: '4px',
},
backgroundImage: {
'arrow-right-up-line': "url('solidus_admin/arrow_right_up_line.svg')",
'arrow-down-s-fill-gray-700': "url('solidus_admin/arrow_down_s_fill_gray_700.svg')",
'arrow-down-s-fill-red-400': "url('solidus_admin/arrow_down_s_fill_red_400.svg')",
},
boxShadow: {
sm: '0px 1px 2px 0px rgba(0, 0, 0, 0.04)',
base: '0px 4px 8px 0px rgba(0, 0, 0, 0.08), 0px 2px 4px -1px rgba(0, 0, 0, 0.04)'
},
},
},
plugins: [
({ addVariant }) => {
addVariant("hidden", "&([hidden])")
addVariant("visible", "&:not([hidden])")
addVariant("search-cancel", "&::-webkit-search-cancel-button")
},
forms({ strategy: "class" }),
containerQueries(),
],
}

document.addEventListener("turbo:render", () => {
document.body.className += " " // This is a hack to trigger TW's JIT compiler
})
</script>
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<!DOCTYPE html>
<html lang="<%= current_locale %>">
<head>
<%= favicon_link_tag 'solidus_admin/favicon.ico' %>
<%= favicon_link_tag "solidus_admin/favicon.ico" %>
<title><%= solidus_admin_title %></title>
<%= stylesheet_link_tag "solidus_admin/application.css", "inter-font", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags "solidus_admin/application", shim: false, importmap: SolidusAdmin.importmap %>
</head>

<body class="bg-gray-15">
<%= render 'layouts/solidus_admin/tailwindcss_cdn' %>

<%= render component("skip_link").new(href: "#main") %>

<div class="flex gap-0">
<div class="min-w-[240px] border-r border-r-gray-100 relative">
<div class="min-h-screen top-0 sticky flex">
Expand Down
1 change: 1 addition & 0 deletions admin/app/views/layouts/solidus_admin/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<%= javascript_importmap_tags "solidus_admin/application", shim: false, importmap: SolidusAdmin.importmap %>
</head>
<body class="p-3">
<%= render 'layouts/solidus_admin/tailwindcss_cdn' %>
<%= yield %>
</body>
</html>
12 changes: 12 additions & 0 deletions admin/config/importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@

pin "stimulus-use", to: "https://ga.jspm.io/npm:[email protected]/dist/index.js"

pin "tailwindcss", to: "https://cdn.tailwindcss.com/3.3.3?plugins=typography,aspect-ratio"
pin "@tailwindcss/aspect-ratio", to: "https://ga.jspm.io/npm:@tailwindcss/[email protected]/src/index.js"
pin "@tailwindcss/container-queries", to: "https://ga.jspm.io/npm:@tailwindcss/[email protected]/dist/index.js"
pin "@tailwindcss/forms", to: "https://ga.jspm.io/npm:@tailwindcss/[email protected]/src/index.js"
pin "@tailwindcss/typography", to: "https://ga.jspm.io/npm:@tailwindcss/[email protected]/src/index.js"

pin "mini-svg-data-uri", to: "https://ga.jspm.io/npm:[email protected]/index.js"
pin "picocolors", to: "https://ga.jspm.io/npm:[email protected]/picocolors.browser.js"
pin "tailwindcss/colors", to: "https://ga.jspm.io/npm:[email protected]/colors.js"
pin "tailwindcss/defaultTheme", to: "https://ga.jspm.io/npm:[email protected]/defaultTheme.js"
pin "tailwindcss/plugin", to: "https://ga.jspm.io/npm:[email protected]/plugin.js"

pin "solidus_admin/application", preload: true
pin "solidus_admin/utils"
pin_all_from SolidusAdmin::Engine.root.join("app/javascript/solidus_admin/controllers"), under: "solidus_admin/controllers"
Expand Down
96 changes: 0 additions & 96 deletions admin/config/solidus_admin/tailwind.config.js.erb

This file was deleted.

Loading