seth_ui 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ecf9dc78341fd20cd1972f3d574dc5a46d2dfbcce52496b47a3f951586c5a414
4
+ data.tar.gz: 85765a8b3c624f305cd80c5fae709a745997fd35987a8f6e6ffb72ba926719e5
5
+ SHA512:
6
+ metadata.gz: e39fe4fbb03ad2a5a960528b3b36eb228ef4399ef5734a25fd636223edef98d3cd64824e5b3c0a497ac31068f4b9c02c3e96df4870d7c13c98b49575e62b2770
7
+ data.tar.gz: cc7cd9f0609d10c2602882caa97d016dc2eefa7d57ee53ad43f0ba2d0b068d9bcdcdcdaf185f4868b4121414a8c34192857f0390471d6439edb4acd9dc868378
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ class Badge < Base
5
+ SIZES = {
6
+ sm: "px-1.5 py-0.5 text-xs",
7
+ md: "px-2 py-1 text-xs",
8
+ lg: "px-3 py-1 text-sm"
9
+ }
10
+
11
+ COLORS = {
12
+ primary: "text-primary bg-primary/5 ring-primary/20",
13
+ secondary: "text-secondary bg-secondary/10 ring-secondary/20",
14
+ outline: "text-foreground bg-background ring-border",
15
+ destructive: "text-destructive bg-destructive/10 ring-destructive/20",
16
+ success: "text-success bg-success/10 ring-success/20",
17
+ warning: "text-warning bg-warning/10 ring-warning/20",
18
+ slate: "text-slate-500 bg-slate-500/10 ring-slate-500/20",
19
+ gray: "text-gray-500 bg-gray-500/10 ring-gray-500/20",
20
+ zinc: "text-zinc-500 bg-zinc-500/10 ring-zinc-500/20",
21
+ neutral: "text-neutral-500 bg-neutral-500/10 ring-neutral-500/20",
22
+ stone: "text-stone-500 bg-stone-500/10 ring-stone-500/20",
23
+ red: "text-red-500 bg-red-500/10 ring-red-500/20",
24
+ orange: "text-orange-500 bg-orange-500/10 ring-orange-500/20",
25
+ amber: "text-amber-500 bg-amber-500/10 ring-amber-500/20",
26
+ yellow: "text-yellow-500 bg-yellow-500/10 ring-yellow-500/20",
27
+ lime: "text-lime-500 bg-lime-500/10 ring-lime-500/20",
28
+ green: "text-green-500 bg-green-500/10 ring-green-500/20",
29
+ emerald: "text-emerald-500 bg-emerald-500/10 ring-emerald-500/20",
30
+ teal: "text-teal-500 bg-teal-500/10 ring-teal-500/20",
31
+ cyan: "text-cyan-500 bg-cyan-500/10 ring-cyan-500/20",
32
+ sky: "text-sky-500 bg-sky-500/10 ring-sky-500/20",
33
+ blue: "text-blue-500 bg-blue-500/10 ring-blue-500/20",
34
+ indigo: "text-indigo-500 bg-indigo-500/10 ring-indigo-500/20",
35
+ violet: "text-violet-500 bg-violet-500/10 ring-violet-500/20",
36
+ purple: "text-purple-500 bg-purple-500/10 ring-purple-500/20",
37
+ fuchsia: "text-fuchsia-500 bg-fuchsia-500/10 ring-fuchsia-500/20",
38
+ pink: "text-pink-500 bg-pink-500/10 ring-pink-500/20",
39
+ rose: "text-rose-500 bg-rose-500/10 ring-rose-500/20"
40
+ }
41
+
42
+ def initialize(variant: :primary, size: :md, **args)
43
+ @variant = variant
44
+ @size = size
45
+ super(**args)
46
+ end
47
+
48
+ def view_template(&)
49
+ span(**attrs, &)
50
+ end
51
+
52
+ private
53
+
54
+ def default_attrs
55
+ {
56
+ class: [ "inline-flex items-center rounded-md font-medium ring-1 ring-inset", SIZES[@size], COLORS[@variant] ]
57
+ }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tailwind_merge"
4
+
5
+ module SethUI
6
+ class Base < Phlex::HTML
7
+ TAILWIND_MERGER = ::TailwindMerge::Merger.new.freeze unless defined?(TAILWIND_MERGER)
8
+
9
+ attr_reader :attrs
10
+
11
+ def initialize(**user_attrs)
12
+ @attrs = mix(default_attrs, user_attrs)
13
+ @attrs[:class] = TAILWIND_MERGER.merge(@attrs[:class]) if @attrs[:class]
14
+ end
15
+
16
+ private
17
+
18
+ def default_attrs
19
+ {}
20
+ end
21
+
22
+ if defined?(Rails) && Rails.env.development?
23
+ def before_template
24
+ comment { "Before #{self.class.name}" }
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ class Button < Base
5
+ BASE_CLASSES = [
6
+ "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors",
7
+ "disabled:pointer-events-none disabled:opacity-50",
8
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
9
+ "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed"
10
+ ].freeze
11
+
12
+ def initialize(type: :button, variant: :primary, size: :md, icon: false, **attrs)
13
+ @type = type
14
+ @variant = variant.to_sym
15
+ @size = size.to_sym
16
+ @icon = icon
17
+ super(**attrs)
18
+ end
19
+
20
+ def view_template(&)
21
+ button(**attrs, &)
22
+ end
23
+
24
+ private
25
+
26
+ def size_classes
27
+ if @icon
28
+ case @size
29
+ when :sm then "h-6 w-6"
30
+ when :md then "h-9 w-9"
31
+ when :lg then "h-10 w-10"
32
+ when :xl then "h-12 w-12"
33
+ end
34
+ else
35
+ case @size
36
+ when :sm then "px-3 py-1.5 h-8 text-xs"
37
+ when :md then "px-4 py-2 h-9 text-sm"
38
+ when :lg then "px-4 py-2 h-10 text-base"
39
+ when :xl then "px-6 py-3 h-12 text-base"
40
+ end
41
+ end
42
+ end
43
+
44
+ def primary_classes
45
+ [
46
+ BASE_CLASSES,
47
+ size_classes,
48
+ "bg-primary text-primary-foreground shadow",
49
+ "hover:bg-primary/90"
50
+ ]
51
+ end
52
+
53
+ def link_classes
54
+ [
55
+ BASE_CLASSES,
56
+ size_classes,
57
+ "text-primary underline-offset-4",
58
+ "hover:underline"
59
+ ]
60
+ end
61
+
62
+ def secondary_classes
63
+ [
64
+ BASE_CLASSES,
65
+ size_classes,
66
+ "bg-secondary text-secondary-foreground",
67
+ "hover:bg-opacity-80"
68
+ ]
69
+ end
70
+
71
+ def destructive_classes
72
+ [
73
+ BASE_CLASSES,
74
+ size_classes,
75
+ "bg-destructive text-white shadow-sm",
76
+ "[a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20",
77
+ "dark:focus-visible:ring-destructive/40 dark:bg-destructive/60"
78
+ ]
79
+ end
80
+
81
+ def outline_classes
82
+ [
83
+ BASE_CLASSES,
84
+ size_classes,
85
+ "border border-input bg-background shadow-sm",
86
+ "hover:bg-accent hover:text-accent-foreground"
87
+ ]
88
+ end
89
+
90
+ def ghost_classes
91
+ [
92
+ BASE_CLASSES,
93
+ size_classes,
94
+ "hover:bg-accent hover:text-accent-foreground"
95
+ ]
96
+ end
97
+
98
+ def default_classes
99
+ case @variant
100
+ when :primary then primary_classes
101
+ when :link then link_classes
102
+ when :secondary then secondary_classes
103
+ when :destructive then destructive_classes
104
+ when :outline then outline_classes
105
+ when :ghost then ghost_classes
106
+ end
107
+ end
108
+
109
+ def default_attrs
110
+ { type: @type, class: default_classes }
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ class Heading < Base
5
+ def initialize(level: nil, as: nil, size: nil, **attrs)
6
+ @level = level
7
+ @as = as
8
+ @size = size
9
+ super(**attrs)
10
+ end
11
+
12
+ def view_template(&)
13
+ tag = determine_tag
14
+ public_send(tag, **attrs, &)
15
+ end
16
+
17
+ private
18
+
19
+ def determine_tag
20
+ return @as if @as
21
+ return "h#{@level}" if @level
22
+ "h1"
23
+ end
24
+
25
+ def default_attrs
26
+ {
27
+ class: class_names
28
+ }
29
+ end
30
+
31
+ def class_names
32
+ base_classes = "scroll-m-20 font-bold tracking-tight"
33
+ size_class = size_to_class[@size || level_to_size[@level] || "6"]
34
+ tag = determine_tag
35
+ "#{base_classes} #{size_class} #{component_specific_classes(tag)}"
36
+ end
37
+
38
+ def component_specific_classes(tag)
39
+ component_classes[tag] || ""
40
+ end
41
+
42
+ def component_classes
43
+ {
44
+ "h1" => "scroll-m-20 text-3xl font-bold leading-normal lg:leading-normal tracking-tight lg:text-4xl",
45
+ "h2" => "scroll-m-20 text-2xl font-semibold tracking-tight transition-colors first:mt-0 pb-4 border-b",
46
+ "h4" => "scroll-m-20 text-lg font-medium tracking-tight"
47
+ }
48
+ end
49
+
50
+ def size_to_class
51
+ {
52
+ "1" => "text-xs",
53
+ "2" => "text-sm",
54
+ "3" => "text-base",
55
+ "4" => "text-lg",
56
+ "5" => "text-xl",
57
+ "6" => "text-2xl",
58
+ "7" => "text-3xl",
59
+ "8" => "text-4xl",
60
+ "9" => "text-5xl"
61
+ }
62
+ end
63
+
64
+ def level_to_size
65
+ {
66
+ "1" => "6",
67
+ "2" => "5",
68
+ "3" => "4",
69
+ "4" => "3"
70
+ }
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ class Link < Base
5
+ BASE_CLASSES = [
6
+ "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors",
7
+ "disabled:pointer-events-none disabled:opacity-50",
8
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
9
+ "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed"
10
+ ].freeze
11
+
12
+ def initialize(href: "#", variant: :link, size: :md, icon: false, **attrs)
13
+ @href = href
14
+ @variant = variant.to_sym
15
+ @size = size.to_sym
16
+ @icon = icon
17
+ super(**attrs)
18
+ end
19
+
20
+ def view_template(&)
21
+ a(href: @href, **attrs, &)
22
+ end
23
+
24
+ private
25
+
26
+ def size_classes
27
+ if @icon
28
+ case @size
29
+ when :sm then "h-6 w-6"
30
+ when :md then "h-9 w-9"
31
+ when :lg then "h-10 w-10"
32
+ when :xl then "h-12 w-12"
33
+ end
34
+ else
35
+ case @size
36
+ when :sm then "px-3 py-1.5 h-8 text-xs"
37
+ when :md then "px-4 py-2 h-9 text-sm"
38
+ when :lg then "px-4 py-2 h-10 text-base"
39
+ when :xl then "px-6 py-3 h-12 text-base"
40
+ end
41
+ end
42
+ end
43
+
44
+ def primary_classes
45
+ [
46
+ BASE_CLASSES,
47
+ size_classes,
48
+ "bg-primary text-primary-foreground shadow",
49
+ "hover:bg-primary/90"
50
+ ]
51
+ end
52
+
53
+ def link_classes
54
+ [
55
+ BASE_CLASSES,
56
+ size_classes,
57
+ "text-primary underline-offset-4",
58
+ "hover:underline"
59
+ ]
60
+ end
61
+
62
+ def secondary_classes
63
+ [
64
+ BASE_CLASSES,
65
+ size_classes,
66
+ "bg-secondary text-secondary-foreground",
67
+ "hover:bg-opacity-80"
68
+ ]
69
+ end
70
+
71
+ def destructive_classes
72
+ [
73
+ BASE_CLASSES,
74
+ size_classes,
75
+ "bg-destructive text-white shadow-sm",
76
+ "[a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20",
77
+ "dark:focus-visible:ring-destructive/40 dark:bg-destructive/60"
78
+ ]
79
+ end
80
+
81
+ def outline_classes
82
+ [
83
+ BASE_CLASSES,
84
+ size_classes,
85
+ "border border-input bg-background shadow-sm",
86
+ "hover:bg-accent hover:text-accent-foreground"
87
+ ]
88
+ end
89
+
90
+ def ghost_classes
91
+ [
92
+ BASE_CLASSES,
93
+ size_classes,
94
+ "hover:bg-accent hover:text-accent-foreground"
95
+ ]
96
+ end
97
+
98
+ def default_classes
99
+ case @variant
100
+ when :primary then primary_classes
101
+ when :link then link_classes
102
+ when :secondary then secondary_classes
103
+ when :destructive then destructive_classes
104
+ when :outline then outline_classes
105
+ when :ghost then ghost_classes
106
+ end
107
+ end
108
+
109
+ def default_attrs
110
+ { type: "button", class: default_classes }
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ class SetDarkMode < Base
5
+ def view_template(&)
6
+ div(**attrs, &)
7
+ end
8
+
9
+ def default_attrs
10
+ {
11
+ class: "hidden dark:inline-block",
12
+ data: { controller: "ruby-ui--theme-toggle", action: "click->ruby-ui--theme-toggle#setLightTheme" }
13
+ }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ class SetLightMode < Base
5
+ def view_template(&)
6
+ div(**attrs, &)
7
+ end
8
+
9
+ def default_attrs
10
+ {
11
+ class: "dark:hidden",
12
+ data: { controller: "ruby-ui--theme-toggle", action: "click->ruby-ui--theme-toggle#setDarkTheme" }
13
+ }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ class ThemeToggle < Base
5
+ def view_template(&)
6
+ div(**attrs, &)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ VERSION = "0.1.0"
5
+ end
data/lib/seth_ui.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SethUI
4
+ VERSION = "0.1.0"
5
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seth_ui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Seth Horsley
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: phlex
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '2.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: tailwind_merge
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.12'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.12'
40
+ description: SethUI is a UI Component Library for Ruby developers. Built on top of
41
+ the Phlex framework.
42
+ executables: []
43
+ extensions: []
44
+ extra_rdoc_files: []
45
+ files:
46
+ - README.md
47
+ - app/components/seth_ui/badge/badge.rb
48
+ - app/components/seth_ui/base.rb
49
+ - app/components/seth_ui/button/button.rb
50
+ - app/components/seth_ui/heading.rb
51
+ - app/components/seth_ui/link/Link.rb
52
+ - app/components/seth_ui/theme_toggle/set_dark_mode.rb
53
+ - app/components/seth_ui/theme_toggle/set_light_mode.rb
54
+ - app/components/seth_ui/theme_toggle/theme_toggle.rb
55
+ - lib/seth_ui.rb
56
+ - lib/seth_ui/version.rb
57
+ homepage: https://rubygems.org/gems/seth_ui
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 4.0.3
76
+ specification_version: 4
77
+ summary: SethUI is a UI Component Library built on Phlex.
78
+ test_files: []