Skip to content

Commit

Permalink
style: 💄 Cleaned up styles using updated tailwind config
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsadam committed Nov 26, 2024
1 parent 51c659f commit 13d15f2
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 80 deletions.
118 changes: 49 additions & 69 deletions embedded_gems/pathogen/app/assets/builds/pathogen_view_components.css
Original file line number Diff line number Diff line change
Expand Up @@ -624,24 +624,29 @@ video {
border-width: 1px;
}

.border-red-100 {
.border-neutral-primary {
--tw-border-opacity: 1;
border-color: rgb(254 226 226 / var(--tw-border-opacity, 1));
border-color: rgb(146 205 184 / var(--tw-border-opacity, 1));
}

.border-slate-200 {
.border-danger-primary {
--tw-border-opacity: 1;
border-color: rgb(226 232 240 / var(--tw-border-opacity, 1));
border-color: rgb(248 113 113 / var(--tw-border-opacity, 1));
}

.bg-slate-50 {
.bg-brand-primary {
--tw-bg-opacity: 1;
background-color: rgb(58 132 108 / var(--tw-bg-opacity, 1));
}

.bg-neutral-secondary {
--tw-bg-opacity: 1;
background-color: rgb(248 250 252 / var(--tw-bg-opacity, 1));
}

.bg-white {
.bg-danger-secondary {
--tw-bg-opacity: 1;
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
background-color: rgb(254 226 226 / var(--tw-bg-opacity, 1));
}

.fill-current {
Expand Down Expand Up @@ -676,39 +681,19 @@ video {
font-weight: 500;
}

.text-red-500 {
.text-brand-onprimary {
--tw-text-opacity: 1;
color: rgb(239 68 68 / var(--tw-text-opacity, 1));
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
}

.text-slate-900 {
.text-neutral-primary {
--tw-text-opacity: 1;
color: rgb(15 23 42 / var(--tw-text-opacity, 1));
color: rgb(30 41 59 / var(--tw-text-opacity, 1));
}

.text-white {
.text-danger-onsecondary {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
}

.transition {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
}

.delay-150 {
transition-delay: 150ms;
}

.duration-300 {
transition-duration: 300ms;
}

.ease-in-out {
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
color: rgb(153 27 27 / var(--tw-text-opacity, 1));
}

.focus\:z-10:focus {
Expand All @@ -726,29 +711,29 @@ video {
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
}

.focus\:ring-red-300:focus {
.focus\:ring-error-100:focus {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(252 165 165 / var(--tw-ring-opacity, 1));
--tw-ring-color: rgb(254 226 226 / var(--tw-ring-opacity, 1));
}

.focus\:ring-slate-100:focus {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(241 245 249 / var(--tw-ring-opacity, 1));
.enabled\:hover\:bg-brand-primary-hover:hover:enabled {
--tw-bg-opacity: 1;
background-color: rgb(71 161 131 / var(--tw-bg-opacity, 1));
}

.enabled\:hover\:bg-red-800:hover:enabled {
.enabled\:hover\:bg-danger-secondary-hover:hover:enabled {
--tw-bg-opacity: 1;
background-color: rgb(153 27 27 / var(--tw-bg-opacity, 1));
background-color: rgb(254 202 202 / var(--tw-bg-opacity, 1));
}

.enabled\:hover\:bg-slate-100:hover:enabled {
--tw-bg-opacity: 1;
background-color: rgb(241 245 249 / var(--tw-bg-opacity, 1));
.enabled\:hover\:text-brand-onsecondary:hover:enabled {
--tw-text-opacity: 1;
color: rgb(45 85 72 / var(--tw-text-opacity, 1));
}

.enabled\:hover\:text-red-50:hover:enabled {
.enabled\:hover\:text-danger-onsecondary:hover:enabled {
--tw-text-opacity: 1;
color: rgb(254 242 242 / var(--tw-text-opacity, 1));
color: rgb(153 27 27 / var(--tw-text-opacity, 1));
}

.disabled\:cursor-not-allowed:disabled {
Expand All @@ -760,58 +745,53 @@ video {
}

@media (prefers-color-scheme: dark) {
.dark\:border-red-800 {
.dark\:border-neutral-primary {
--tw-border-opacity: 1;
border-color: rgb(153 27 27 / var(--tw-border-opacity, 1));
border-color: rgb(146 205 184 / var(--tw-border-opacity, 1));
}

.dark\:border-slate-600 {
.dark\:border-danger-primary {
--tw-border-opacity: 1;
border-color: rgb(71 85 105 / var(--tw-border-opacity, 1));
border-color: rgb(248 113 113 / var(--tw-border-opacity, 1));
}

.dark\:bg-slate-800 {
.dark\:bg-neutral-primary {
--tw-bg-opacity: 1;
background-color: rgb(30 41 59 / var(--tw-bg-opacity, 1));
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
}

.dark\:bg-slate-900 {
.dark\:bg-danger-secondary {
--tw-bg-opacity: 1;
background-color: rgb(15 23 42 / var(--tw-bg-opacity, 1));
background-color: rgb(254 226 226 / var(--tw-bg-opacity, 1));
}

.dark\:text-red-500 {
.dark\:text-neutral-secondary {
--tw-text-opacity: 1;
color: rgb(239 68 68 / var(--tw-text-opacity, 1));
color: rgb(100 116 139 / var(--tw-text-opacity, 1));
}

.dark\:text-slate-400 {
.dark\:text-danger-onsecondary {
--tw-text-opacity: 1;
color: rgb(148 163 184 / var(--tw-text-opacity, 1));
color: rgb(153 27 27 / var(--tw-text-opacity, 1));
}

.dark\:focus\:ring-red-900:focus {
.dark\:focus\:ring-error-900:focus {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(127 29 29 / var(--tw-ring-opacity, 1));
}

.dark\:focus\:ring-slate-700:focus {
--tw-ring-opacity: 1;
--tw-ring-color: rgb(51 65 85 / var(--tw-ring-opacity, 1));
}

.enabled\:dark\:hover\:bg-slate-700:hover:enabled {
.enabled\:dark\:hover\:bg-neutral-primary:hover:enabled {
--tw-bg-opacity: 1;
background-color: rgb(51 65 85 / var(--tw-bg-opacity, 1));
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
}

.enabled\:dark\:hover\:text-red-50:hover:enabled {
.enabled\:dark\:hover\:text-brand-onprimary:hover:enabled {
--tw-text-opacity: 1;
color: rgb(254 242 242 / var(--tw-text-opacity, 1));
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
}

.enabled\:dark\:hover\:text-white:hover:enabled {
.enabled\:dark\:hover\:text-danger-onsecondary:hover:enabled {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
color: rgb(153 27 27 / var(--tw-text-opacity, 1));
}
}
8 changes: 4 additions & 4 deletions embedded_gems/pathogen/app/components/pathogen/button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Button < Pathogen::Component
SCHEME_OPTIONS = %i[primary default danger].freeze
DEFAULT_SCHEME = :default
# rubocop:disable Layout/LineLength
DEFAULT_CLASSES = 'relative pointer select-none transition ease-in-out delay-150 duration-300 rounded-lg font-medium focus:outline-none focus:ring-4 focus:z-10 disabled:opacity-70 disabled:cursor-not-allowed'
DEFAULT_CLASSES = 'relative pointer select-none rounded-lg font-medium focus:outline-none focus:ring-4 focus:z-10 disabled:opacity-70 disabled:cursor-not-allowed'
# rubocop:enable Layout/LineLength

# rubocop:disable Metrics/ParameterLists
Expand Down Expand Up @@ -74,9 +74,9 @@ def trimmed_content
def generate_scheme_mapping(scheme)
# rubocop:disable Layout/LineLength
{
primary: 'bg-primary-700 text-white enabled:hover:bg-primary-800 focus:ring-primary-100 dark:focus:ring-primary-600',
default: 'text-slate-900 bg-white border border-slate-200 enabled:hover:bg-slate-100 enabled:hover:text-primary-700 focus:ring-4 focus:ring-slate-100 dark:focus:ring-slate-700 dark:bg-slate-800 dark:text-slate-400 dark:border-slate-600 enabled:dark:hover:text-white enabled:dark:hover:bg-slate-700',
danger: 'border border-red-100 bg-slate-50 text-red-500 enabled:hover:text-red-50 enabled:dark:hover:text-red-50 enabled:hover:bg-red-800 focus:ring-red-300 dark:border-red-800 dark:bg-slate-900 dark:text-red-500 dark:focus:ring-red-900'
primary: 'bg-brand-primary text-brand-onprimary enabled:hover:bg-brand-primary-hover focus:ring-brand-primary-100 dark:focus:ring-brand-primary-600',
default: 'text-neutral-primary bg-neutral-secondary border border-neutral-primary enabled:hover:bg-neutral-secondary-hover enabled:hover:text-brand-onsecondary focus:ring-4 focus:ring-neutral-primary dark:focus:ring-neutral-primary dark:bg-neutral-primary dark:text-neutral-secondary dark:border-neutral-primary enabled:dark:hover:text-brand-onprimary enabled:dark:hover:bg-neutral-primary dark:enabled:hover:bg-neutral-primary-hover',
danger: 'border border-danger-primary bg-danger-secondary text-danger-onsecondary enabled:hover:text-danger-onsecondary enabled:dark:hover:text-danger-onsecondary enabled:hover:bg-danger-secondary-hover focus:ring-danger-primary-100 dark:border-danger-primary dark:bg-danger-secondary dark:text-danger-onsecondary dark:focus:ring-danger-primary-900'
}[scheme]
# rubocop:enable Layout/LineLength
end
Expand Down
1 change: 1 addition & 0 deletions embedded_gems/pathogen/demo/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ end
gem "hotwire-livereload", "~> 1.4", :group => :development

gem "tailwindcss-rails", "~> 3.0"
gem "heroicon-rails", "~> 0.2.9"
1 change: 1 addition & 0 deletions embedded_gems/pathogen/demo/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ DEPENDENCIES
brakeman
capybara
debug
heroicon-rails (~> 0.2.9)
hotwire-livereload (~> 1.4)
importmap-rails
jbuilder
Expand Down
88 changes: 85 additions & 3 deletions embedded_gems/pathogen/previews/pathogen/button_preview.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,91 @@
# frozen_string_literal: true

module Pathogen
# Preview class for Primer::Button component
class ButtonPreview < ViewComponent::Preview
# @label Default
def default; end
# @param scheme select { choices: [default,primary, danger] } "The color scheme of the button."
# @param size select { choices: [small, medium] } "The size of the button."
# @param disabled toggle "The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants."
# @param block toggle "If true, the button will take up the full width of its container."
def playground(scheme: :default, size: :medium, disabled: false, block: false)
render Pathogen::Button.new(scheme:, size:, disabled:, block:, test_selector: 'playground') do
'Button'
end
end

# @param disabled toggle "The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants."
def default(disabled: false)
render Pathogen::Button.new(disabled:, test_selector: 'default') do
'Button'
end
end

# @param disabled toggle "The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants."
# @param block toggle "If true, the button will take up the full width of its container."
def primary(disabled: false, block: false)
render Pathogen::Button.new(scheme: :primary, disabled:, block:, test_selector: 'primary') do
'Button'
end
end

# @param disabled toggle "The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants."
# @param block toggle "If true, the button will take up the full width of its container."
def danger(disabled: false, block: false)
render Pathogen::Button.new(scheme: :danger, disabled:, block:, test_selector: 'danger') do
'Button'
end
end

def all_schemes; end

def full_width
render Pathogen::Button.new(block: true, test_selector: 'full-width') do
'Button'
end
end

# @param scheme select { choices: [default,primary, danger] } "The color scheme of the button."
# @param href text "The URL to link to."
# @param disabled toggle "The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants."
def link_as_a_button(scheme: :default, href: '#', disabled: false)
render Pathogen::Button.new(scheme:, href:, tag: :a, disabled:, test_selector: 'link-as-a-button') do
'Button'
end
end

# @param scheme select { choices: [default,primary, danger] } "The color scheme of the button."
# @param size select { choices: [small, medium] } "The size of the button."
def leading_visual(scheme: :primary, size: :medium)
render_with_template(locals: {
scheme:,
size:
})
end

# @param scheme select { choices: [default,primary, danger] } "The color scheme of the button."
# @param size select { choices: [small, medium] } "The size of the button."
def leading_visual_svg(scheme: :primary, size: :medium)
render_with_template(locals: {
scheme:,
size:
})
end

# @param scheme select { choices: [default,primary, danger] } "The color scheme of the button."
# @param size select { choices: [small, medium] } "The size of the button."
def trailing_visual(scheme: :primary, size: :medium)
render_with_template(locals: {
scheme:,
size:
})
end

# @param scheme select { choices: [default,primary, danger] } "The color scheme of the button."
# @param size select { choices: [small, medium] } "The size of the button."
def trailing_visual_svg(scheme: :primary, size: :medium)
render_with_template(locals: {
scheme:,
size:
})
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="grid grid-cols-3 gap-4">
<%= render Pathogen::Button.new(scheme: :default) do %>
Button
<% end %>

<%= render Pathogen::Button.new(scheme: :primary) do %>
Button
<% end %>

<%= render Pathogen::Button.new(scheme: :danger) do %>
Button
<% end %>
</div>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%= render Pathogen::Button.new(scheme:, size:) do |button| %>
<% button.with_leading_visual_icon(icon: "magnifying-glass") %>
Search
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%= render Pathogen::Button.new(scheme:, size:) do |button| %>
<% button.with_leading_visual_svg do %>
<path
d="M8 16a2 2 0 001.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 008 16z"
></path><path
fill-rule="evenodd"
d="M8 1.5A3.5 3.5 0 004.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.018.018 0 00-.003.01l.001.006c0 .002.002.004.004.006a.017.017 0 00.006.004l.007.001h10.964l.007-.001a.016.016 0 00.006-.004.016.016 0 00.004-.006l.001-.007a.017.017 0 00-.003-.01l-1.703-2.554a1.75 1.75 0 01-.294-.97V5A3.5 3.5 0 008 1.5zM3 5a5 5 0 0110 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.518 1.518 0 0113.482 13H2.518a1.518 1.518 0 01-1.263-2.36l1.703-2.554A.25.25 0 003 7.947V5z"
></path>
<% end %>
Warning
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%= render Pathogen::Button.new(scheme:, size:) do |button| %>
<% button.with_trailing_visual_icon(icon: "arrow-right") %>
Proceed
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= render Pathogen::Button.new(scheme:, size:) do |button| %>
<% button.with_trailing_visual_svg do %>
<path
d="M8 16a2 2 0 001.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 008 16z"
></path><path
fill-rule="evenodd"
d="M8 1.5A3.5 3.5 0 004.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.018.018 0 00-.003.01l.001.006c0 .002.002.004.004.006a.017.017 0 00.006.004l.007.001h10.964l.007-.001a.016.016 0 00.006-.004.016.016 0 00.004-.006l.001-.007a.017.017 0 00-.003-.01l-1.703-2.554a1.75 1.75 0 01-.294-.97V5A3.5 3.5 0 008 1.5zM3 5a5 5 0 0110 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.518 1.518 0 0113.482 13H2.518a1.518 1.518 0 01-1.263-2.36l1.703-2.554A.25.25 0 003 7.947V5z"
></path>

<% end %>
Warning
<% end %>
Loading

0 comments on commit 13d15f2

Please sign in to comment.