keystone_ui 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24cf791aa7574c54fce5bde514cd2c23c9f1ed4ea3d1f8b878ed13bc544ec380
4
- data.tar.gz: f36f715a3d2423e4cf94480785088673f481d3cbe5f9d46d8bd3013c977a4e2f
3
+ metadata.gz: 1ba08014c8024c4d2be934c04bf5986fabf96067a28816c89b27a68593865878
4
+ data.tar.gz: 22c8e2fe139a1cb802d7c7e694f54aa95f627f2a8eb0808f9ec65db78a5762ab
5
5
  SHA512:
6
- metadata.gz: cefa7a60ca4be4b4aa123e60d26f623729f2c970fa3f581f17024858c713623484dc95f74bb0366f9d6c928c0a5c6f7480975403c65a5ceed1ccb81dd6b4ea33
7
- data.tar.gz: 227693a252c9131d146089eaf36530a68d6994278233d81fd9c716f51a66af3bf4286fb3f0dc2f930f4589bac2f9bc82818c56ffba2abd18486610b77aa2544d
6
+ metadata.gz: 8115ce638bb73b100305498b251d5ce6a8d4993d82587061f74dfe24f04f5c039f5bfc33158661daf8d6e305e8c9b866c78ef70102be03e1a7da892b02170ffe
7
+ data.tar.gz: 7f92473cf68ce1eda055362700d86ac278844b4825763ea7b304dad3ddc0d2a2661b1572b8808a9d5043b36fafaf3518ebb00908b04f01f09910d9c74d08ce70
@@ -3,35 +3,30 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class AlertComponent < ViewComponent::Base
6
- BASE_CLASSES = "rounded-md p-4"
7
-
8
6
  TYPE_CLASSES = {
9
- success: "bg-green-50 text-green-800 dark:bg-green-900/30 dark:text-green-300",
10
- warning: "bg-yellow-50 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300",
11
- error: "bg-red-50 text-red-800 dark:bg-red-900/30 dark:text-red-300"
7
+ info: "ks-alert-info",
8
+ success: "ks-alert-success",
9
+ warning: "ks-alert-warning",
10
+ error: "ks-alert-error"
12
11
  }.freeze
13
12
 
14
- OUTER_CLASSES = "flex"
15
- INNER_CLASSES = "flex-1"
16
- TITLE_CLASSES = "font-semibold"
17
- MESSAGE_CLASSES = "text-sm"
18
- MESSAGE_WITH_TITLE_CLASSES = "text-sm mt-1"
19
- DISMISS_CLASSES = "ml-auto -mr-1.5 -mt-1.5 inline-flex rounded-md p-1.5 focus:outline-none focus:ring-2 focus:ring-offset-2 cursor-pointer"
13
+ OUTER_CLASSES = "ks-alert-body"
14
+ INNER_CLASSES = "ks-alert-content"
15
+ TITLE_CLASSES = "ks-alert-title"
16
+ MESSAGE_CLASSES = "ks-alert-message"
17
+ MESSAGE_WITH_TITLE_CLASSES = "ks-alert-message-titled"
18
+ DISMISS_CLASSES = "ks-alert-dismiss"
20
19
 
21
- def initialize(message:, type: :info, title: nil, dismissible: false)
20
+ def initialize(message:, type: :info, title: nil, dismissible: false, class: nil)
22
21
  @message = message
23
22
  @type = type
24
23
  @title = title
25
24
  @dismissible = dismissible
25
+ @extra_classes = binding.local_variable_get(:class)
26
26
  end
27
27
 
28
28
  def classes
29
- type_css = if @type == :info
30
- "bg-accent-50 text-accent-800 dark:bg-accent-900/30 dark:text-accent-300"
31
- else
32
- TYPE_CLASSES.fetch(@type)
33
- end
34
- "#{BASE_CLASSES} #{type_css}"
29
+ [ "ks-alert", TYPE_CLASSES.fetch(@type), @extra_classes ].compact.join(" ")
35
30
  end
36
31
 
37
32
  def message_text
@@ -3,25 +3,24 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class BadgeComponent < ViewComponent::Base
6
- BASE_CLASSES = "inline-flex items-center rounded-full px-2 py-1 text-xs font-medium"
7
-
8
6
  VARIANT_CLASSES = {
9
- neutral: "bg-gray-100 text-gray-700 dark:bg-zinc-700 dark:text-gray-300",
10
- success: "bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",
11
- danger: "bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-400",
12
- warning: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-400",
13
- info: "bg-accent-100 text-accent-700 dark:bg-accent-900/50 dark:text-accent-400"
7
+ neutral: "ks-badge-neutral",
8
+ success: "ks-badge-success",
9
+ danger: "ks-badge-danger",
10
+ warning: "ks-badge-warning",
11
+ info: "ks-badge-info"
14
12
  }.freeze
15
13
 
16
14
  attr_reader :label
17
15
 
18
- def initialize(label:, variant: :neutral)
16
+ def initialize(label:, variant: :neutral, class: nil)
19
17
  @label = label
20
18
  @variant = variant
19
+ @extra_classes = binding.local_variable_get(:class)
21
20
  end
22
21
 
23
22
  def classes
24
- "#{BASE_CLASSES} #{VARIANT_CLASSES.fetch(@variant)}"
23
+ [ "ks-badge", VARIANT_CLASSES.fetch(@variant), @extra_classes ].compact.join(" ")
25
24
  end
26
25
  end
27
26
  end
@@ -3,30 +3,31 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class CardComponent < ViewComponent::Base
6
- CARD_CLASSES = "overflow-hidden rounded-lg border border-gray-200 bg-white dark:bg-zinc-900 dark:border-zinc-700"
7
- CARD_EDGE_CLASSES = "overflow-hidden border-y border-gray-200 bg-white sm:rounded-lg sm:border-x dark:bg-zinc-900 dark:border-zinc-700"
8
- BODY_CLASSES = "px-4 py-4 sm:px-6 sm:pt-6 sm:pb-4"
9
- CTA_CLASSES = "px-4 pb-4 sm:px-6 sm:pb-6"
10
- TITLE_CLASSES = "text-lg font-semibold text-gray-900 dark:text-white m-0"
11
- SUMMARY_CLASSES = "mt-1 text-sm text-gray-500 dark:text-gray-400 mb-0"
12
- LINK_BASE_CLASSES = "text-sm font-medium no-underline"
6
+ CARD_CLASSES = "ks-card"
7
+ CARD_EDGE_CLASSES = "ks-card-edge"
8
+ BODY_CLASSES = "ks-card-body"
9
+ CTA_CLASSES = "ks-card-cta"
10
+ TITLE_CLASSES = "ks-card-title"
11
+ SUMMARY_CLASSES = "ks-card-summary"
12
+ LINK_CLASSES = "ks-card-link"
13
13
 
14
- def initialize(title:, summary:, link:, cta: "Read more", edge_to_edge: false)
14
+ def initialize(title:, summary:, link:, cta: "Read more", edge_to_edge: false, class: nil)
15
15
  @title = title
16
16
  @summary = summary
17
17
  @link = link
18
18
  @cta = cta
19
19
  @edge_to_edge = edge_to_edge
20
+ @extra_classes = binding.local_variable_get(:class)
20
21
  end
21
22
 
22
23
  def link_classes
23
- "#{LINK_BASE_CLASSES} text-accent-600 hover:text-accent-900 dark:text-accent-400"
24
+ LINK_CLASSES
24
25
  end
25
26
 
26
27
  private
27
28
 
28
29
  def card_classes
29
- @edge_to_edge ? CARD_EDGE_CLASSES : CARD_CLASSES
30
+ [ @edge_to_edge ? CARD_EDGE_CLASSES : CARD_CLASSES, @extra_classes ].compact.join(" ")
30
31
  end
31
32
  end
32
33
  end
@@ -4,26 +4,27 @@ module Keystone
4
4
  module Ui
5
5
  class PageComponent < ViewComponent::Base
6
6
  MAX_WIDTH_CLASSES = {
7
- sm: "max-w-2xl",
8
- md: "max-w-4xl",
9
- lg: "max-w-6xl",
10
- xl: "max-w-7xl",
7
+ sm: "ks-page-sm",
8
+ md: "ks-page-md",
9
+ lg: "ks-page-lg",
10
+ xl: "ks-page-xl",
11
11
  full: ""
12
12
  }.freeze
13
13
 
14
- PADDING_CLASSES = "px-4 py-4 sm:px-6 lg:px-8"
14
+ PADDING_CLASSES = "ks-page"
15
15
 
16
16
  TOP_OFFSET_CLASSES = {
17
- sm: "pt-12",
18
- md: "pt-16",
19
- lg: "pt-20",
20
- xl: "pt-24"
17
+ sm: "ks-page-offset-sm",
18
+ md: "ks-page-offset-md",
19
+ lg: "ks-page-offset-lg",
20
+ xl: "ks-page-offset-xl"
21
21
  }.freeze
22
22
 
23
- def initialize(max_width: :full, padding: :standard, top_offset: nil)
23
+ def initialize(max_width: :full, padding: :standard, top_offset: nil, class: nil)
24
24
  @max_width = max_width
25
25
  @padding = padding
26
26
  @top_offset = top_offset
27
+ @extra_classes = binding.local_variable_get(:class)
27
28
  end
28
29
 
29
30
  def classes
@@ -32,7 +33,7 @@ module Keystone
32
33
  tokens << TOP_OFFSET_CLASSES.fetch(@top_offset) if @top_offset
33
34
  width_class = MAX_WIDTH_CLASSES.fetch(@max_width)
34
35
  tokens << width_class unless width_class.empty?
35
- tokens << "mx-auto" unless @max_width == :full
36
+ tokens << @extra_classes if @extra_classes
36
37
  tokens.join(" ")
37
38
  end
38
39
  end
@@ -2,7 +2,7 @@
2
2
  <% content_for :mobile_action_url, action_url %>
3
3
  <% content_for :mobile_action_label, action_label %>
4
4
  <% end %>
5
- <div class="<%= WRAPPER_CLASSES %>">
5
+ <div class="<%= wrapper_classes %>">
6
6
  <div>
7
7
  <h1 class="<%= TITLE_CLASSES %>"><%= @title %></h1>
8
8
  <% if subtitle? %>
@@ -3,19 +3,24 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class PageHeaderComponent < ViewComponent::Base
6
- WRAPPER_CLASSES = "hidden sm:block mb-6 sm:flex sm:items-center sm:justify-between"
7
- TITLE_CLASSES = "text-2xl font-bold text-gray-900 dark:text-white"
8
- SUBTITLE_CLASSES = "mt-1 text-sm text-gray-500 dark:text-gray-400"
9
- ACTIONS_CLASSES = "page-header-actions hidden sm:block mt-4 sm:mt-0 sm:ml-4 flex-shrink-0"
6
+ WRAPPER_CLASSES = "ks-page-header"
7
+ TITLE_CLASSES = "ks-page-header-title"
8
+ SUBTITLE_CLASSES = "ks-page-header-subtitle"
9
+ ACTIONS_CLASSES = "page-header-actions ks-page-header-actions"
10
10
 
11
11
  attr_reader :title, :action_url, :action_label
12
12
 
13
- def initialize(title:, subtitle: nil, action_url: nil, action_label: "Add new")
13
+ def initialize(title:, subtitle: nil, action_url: nil, action_label: "Add new", class: nil)
14
14
  @title = title
15
15
  @subtitle = subtitle
16
16
  @action_url = action_url
17
17
  @action_label = action_label
18
18
  @action_block = nil
19
+ @extra_classes = binding.local_variable_get(:class)
20
+ end
21
+
22
+ def wrapper_classes
23
+ [ WRAPPER_CLASSES, @extra_classes ].compact.join(" ")
19
24
  end
20
25
 
21
26
  def before_render
@@ -1,4 +1,4 @@
1
- <div class="<%= spacing_class %>">
1
+ <div class="<%= classes %>">
2
2
  <% if header? %>
3
3
  <div class="<%= HEADER_CLASSES %>">
4
4
  <div>
@@ -3,25 +3,30 @@
3
3
  module Keystone
4
4
  module Ui
5
5
  class SectionComponent < ViewComponent::Base
6
- SPACING_CLASSES = { sm: "mt-4", md: "mt-6", lg: "mt-8" }.freeze
7
- HEADER_CLASSES = "flex items-center justify-between mb-4"
8
- TITLE_CLASSES = "text-lg font-semibold text-gray-900 dark:text-white"
9
- SUBTITLE_CLASSES = "mt-1 text-sm text-gray-500 dark:text-gray-400"
10
- ACTION_BASE_CLASSES = "text-sm"
6
+ SPACING_CLASSES = { sm: "ks-section-sm", md: "ks-section-md", lg: "ks-section-lg" }.freeze
7
+ HEADER_CLASSES = "ks-section-header"
8
+ TITLE_CLASSES = "ks-section-title"
9
+ SUBTITLE_CLASSES = "ks-section-subtitle"
10
+ ACTION_CLASSES = "ks-section-action"
11
11
 
12
- def initialize(title: nil, subtitle: nil, action: nil, spacing: :md)
12
+ def initialize(title: nil, subtitle: nil, action: nil, spacing: :md, class: nil)
13
13
  @title = title
14
14
  @subtitle = subtitle
15
15
  @action = action
16
16
  @spacing = spacing
17
+ @extra_classes = binding.local_variable_get(:class)
17
18
  end
18
19
 
19
20
  def spacing_class
20
21
  SPACING_CLASSES.fetch(@spacing)
21
22
  end
22
23
 
24
+ def classes
25
+ [ spacing_class, @extra_classes ].compact.join(" ")
26
+ end
27
+
23
28
  def action_classes
24
- "#{ACTION_BASE_CLASSES} text-accent-600 hover:text-accent-900 dark:text-accent-400 dark:hover:text-accent-300"
29
+ ACTION_CLASSES
25
30
  end
26
31
 
27
32
  def header?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.11.1"
4
+ VERSION = "0.12.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.1
19
+ version: 0.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.1
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: view_component
29
29
  requirement: !ruby/object:Gem::Requirement