phlexy_ui 0.1.1

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: 649e11b247a2b1cb86b47caaba5c5fbf69210a6f563aaf05bdc86d97799faf8f
4
+ data.tar.gz: 64c75e9f793b708663902157539672abf743407100d247093467d7f94473b735
5
+ SHA512:
6
+ metadata.gz: b1a9b52e5ca14871a3aea5d2f792dd8d549ca7a31cb4dd06bfbd90573998768db3ece9752d9a27af1b2d2fed2f0aea8c7ffd8efdec1373a306a74556a19b235f
7
+ data.tar.gz: 3ab85f2c5f6d9a09c04d57bf978c43d82abb2ed3e4157e55b5de179c7b4a7b38c60ef1e619a491512a18590799d803ad36f40c279fbc3dd36fad89fe710482f5
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ class Base < Phlex::HTML
5
+ def initialize(*normal_conditions, sm: [], md: [], lg: [], **options)
6
+ @normal_conditions = normal_conditions
7
+ @sm_conditions = Array(sm)
8
+ @md_conditions = Array(md)
9
+ @lg_conditions = Array(lg)
10
+ @options = options
11
+ @data = options.delete(:data)
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :normal_conditions,
17
+ :sm_conditions,
18
+ :md_conditions,
19
+ :lg_conditions,
20
+ :options,
21
+ :data,
22
+ :as
23
+
24
+ def classes
25
+ [
26
+ prefixed(self.class::BASE_HTML_CLASS),
27
+ *html_classes_for_conditions(normal_conditions),
28
+ *html_classes_for_conditions(sm_conditions, responsive_prefix: :sm),
29
+ *html_classes_for_conditions(md_conditions, responsive_prefix: :md),
30
+ *html_classes_for_conditions(lg_conditions, responsive_prefix: :lg)
31
+ ]
32
+ end
33
+
34
+ def html_classes_for_conditions(conditions, responsive_prefix: nil)
35
+ conditions.map do |condition|
36
+ class_name = prefixed self.class::CONDITIONS_CLASSES.fetch(condition)
37
+
38
+ responsive_prefix ? "#{responsive_prefix}:#{class_name}" : class_name
39
+ end
40
+ rescue KeyError => e
41
+ raise ArgumentError, "Condition `#{e.key}` is not defined for #{self.class}"
42
+ end
43
+
44
+ def prefixed(string)
45
+ "#{PhlexyUI.configuration.prefix}#{string}"
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ class Button < Base
5
+ CONDITIONS_CLASSES = {
6
+ # Modifiers
7
+ no_animation: "no-animation",
8
+ glass: "glass",
9
+ ghost: "btn-ghost",
10
+ link: "btn-link",
11
+ outline: "btn-outline",
12
+ active: "btn-active",
13
+ disabled: "btn-disabled",
14
+ lg: "btn-lg",
15
+ md: "btn-md",
16
+ sm: "btn-sm",
17
+ xs: "btn-xs",
18
+ wide: "btn-wide",
19
+ block: "btn-block",
20
+ circle: "btn-circle",
21
+ square: "btn-square",
22
+ # Colors
23
+ neutral: "btn-neutral",
24
+ primary: "btn-primary",
25
+ secondary: "btn-secondary",
26
+ accent: "btn-accent",
27
+ info: "btn-info",
28
+ success: "btn-success",
29
+ warning: "btn-warning",
30
+ error: "btn-error"
31
+ }.freeze
32
+
33
+ BASE_HTML_CLASS = "btn"
34
+
35
+ def view_template(&)
36
+ button(class: classes, data:, &)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ class Card < Base
5
+ CONDITIONS_CLASSES = {
6
+ # Modifiers
7
+ image_full: "image-full",
8
+ bordered: "card-bordered",
9
+ normal: "card-normal",
10
+ compact: "card-compact",
11
+ side: "card-side"
12
+ }.freeze
13
+
14
+ BASE_HTML_CLASS = "card"
15
+
16
+ def initialize(*, as: :section, **)
17
+ super(*, **)
18
+ @as = as
19
+ end
20
+
21
+ def view_template(&)
22
+ public_send(as, class: classes, data: data, &)
23
+ end
24
+
25
+ def body(**options, &)
26
+ classes = ["card-body", options.delete(:class)]
27
+
28
+ div(class: classes, **options, &)
29
+ end
30
+
31
+ def title(**options, &)
32
+ classes = ["card-title", options.delete(:class)]
33
+
34
+ header(class: classes, **options, &)
35
+ end
36
+
37
+ def actions(**options, &)
38
+ classes = ["card-actions", options.delete(:class)]
39
+
40
+ footer(class: classes, **options, &)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,21 @@
1
+ module PhlexyUI
2
+ module Configurable
3
+ def configure
4
+ self.configuration ||= Configuration.new
5
+ yield(configuration) if block_given?
6
+ configuration
7
+ end
8
+
9
+ def configuration
10
+ @configuration ||= Configuration.new
11
+ end
12
+
13
+ class Configuration
14
+ attr_accessor :prefix
15
+
16
+ def initialize
17
+ @prefix = nil
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ VERSION = "0.1.0"
5
+ end
data/lib/phlexy_ui.rb ADDED
@@ -0,0 +1,18 @@
1
+ require "phlex"
2
+ require "zeitwerk"
3
+ require_relative "phlexy_ui/version"
4
+
5
+ loader = Zeitwerk::Loader.for_gem
6
+ loader.inflector.inflect(
7
+ "phlexy_ui" => "PhlexyUI"
8
+ )
9
+ loader.setup # ready!
10
+
11
+ module PhlexyUI
12
+ extend Configurable
13
+ extend Phlex::Kit
14
+
15
+ autoload :Button, "phlexy_ui/button"
16
+ end
17
+
18
+ loader.eager_load
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phlexy_ui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - David Alejandro Aguilar Ramos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-08-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: phlex
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: zeitwerk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: standard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: PhlexyUI is a Ruby UI component library for DaisyUI using Phlex
70
+ email: boil-dosage.0p@icloud.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/phlexy_ui.rb
76
+ - lib/phlexy_ui/base.rb
77
+ - lib/phlexy_ui/button.rb
78
+ - lib/phlexy_ui/card.rb
79
+ - lib/phlexy_ui/configurable.rb
80
+ - lib/phlexy_ui/version.rb
81
+ homepage: https://rubygems.org/gems/phlexy_ui
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ source_code_uri: https://github.com/PhlexyUI/phlexy_ui
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '3.2'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.5.10
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: PhlexyUI is a Ruby UI component library for DaisyUI using Phlex
105
+ test_files: []