flowbite-components 0.1.4 → 0.3.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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -4
  3. data/README.md +23 -4
  4. data/app/components/flowbite/badge/badge.html.erb +4 -0
  5. data/app/components/flowbite/badge/dot.rb +45 -0
  6. data/app/components/flowbite/badge/pill.rb +40 -0
  7. data/app/components/flowbite/badge.rb +116 -0
  8. data/app/components/flowbite/breadcrumb/home_icon.rb +28 -0
  9. data/app/components/flowbite/breadcrumb/item/current.rb +35 -0
  10. data/app/components/flowbite/breadcrumb/item/first.rb +37 -0
  11. data/app/components/flowbite/breadcrumb/item.rb +50 -0
  12. data/app/components/flowbite/breadcrumb/separator_icon.rb +34 -0
  13. data/app/components/flowbite/breadcrumb.rb +54 -0
  14. data/app/components/flowbite/button.rb +6 -5
  15. data/app/components/flowbite/card.rb +15 -1
  16. data/app/components/flowbite/input/checkbox.rb +2 -2
  17. data/app/components/flowbite/input/date.rb +2 -2
  18. data/app/components/flowbite/input/date_time.rb +11 -0
  19. data/app/components/flowbite/input/email.rb +2 -2
  20. data/app/components/flowbite/input/file.rb +2 -2
  21. data/app/components/flowbite/input/hint.rb +6 -1
  22. data/app/components/flowbite/input/label.rb +1 -1
  23. data/app/components/flowbite/input/number.rb +2 -2
  24. data/app/components/flowbite/input/password.rb +2 -2
  25. data/app/components/flowbite/input/phone.rb +2 -2
  26. data/app/components/flowbite/input/radio_button.rb +2 -2
  27. data/app/components/flowbite/input/select.rb +2 -2
  28. data/app/components/flowbite/input/textarea.rb +2 -2
  29. data/app/components/flowbite/input/url.rb +2 -2
  30. data/app/components/flowbite/input/validation_error.rb +1 -1
  31. data/app/components/flowbite/input.rb +155 -0
  32. data/app/components/flowbite/input_field/checkbox.rb +7 -7
  33. data/app/components/flowbite/input_field/date_time.rb +13 -0
  34. data/app/components/flowbite/input_field/input_field.html.erb +2 -2
  35. data/app/components/flowbite/input_field/radio_button.rb +9 -15
  36. data/app/components/flowbite/input_field/select.rb +1 -1
  37. data/app/components/flowbite/input_field.rb +120 -69
  38. data/app/components/flowbite/link.rb +2 -0
  39. data/app/components/flowbite/sidebar/item.rb +68 -0
  40. data/app/components/flowbite/sidebar/navigation.rb +62 -0
  41. data/app/components/flowbite/sidebar.rb +62 -0
  42. data/app/components/flowbite/toast/icon.html.erb +5 -0
  43. data/app/components/flowbite/toast/icon.rb +57 -0
  44. data/app/components/flowbite/toast/toast.html.erb +40 -0
  45. data/app/components/flowbite/toast.rb +37 -0
  46. data/lib/flowbite/components/version.rb +1 -1
  47. data/lib/yard/flowbite_viewcomponent.rb +24 -0
  48. metadata +40 -5
  49. data/app/components/flowbite/input/field.rb +0 -126
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowbite-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Skjerning
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: 4.0.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: yard
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
26
40
  description: A library of View Components based on the Flowbite design system to be
27
41
  used in Rails applications.
28
42
  email:
@@ -35,16 +49,27 @@ files:
35
49
  - LICENSE
36
50
  - README.md
37
51
  - app/assets/tailwind/flowbite_components/engine.css
52
+ - app/components/flowbite/badge.rb
53
+ - app/components/flowbite/badge/badge.html.erb
54
+ - app/components/flowbite/badge/dot.rb
55
+ - app/components/flowbite/badge/pill.rb
56
+ - app/components/flowbite/breadcrumb.rb
57
+ - app/components/flowbite/breadcrumb/home_icon.rb
58
+ - app/components/flowbite/breadcrumb/item.rb
59
+ - app/components/flowbite/breadcrumb/item/current.rb
60
+ - app/components/flowbite/breadcrumb/item/first.rb
61
+ - app/components/flowbite/breadcrumb/separator_icon.rb
38
62
  - app/components/flowbite/button.rb
39
63
  - app/components/flowbite/button/outline.rb
40
64
  - app/components/flowbite/button/pill.rb
41
65
  - app/components/flowbite/card.rb
42
66
  - app/components/flowbite/card/card.html.erb
43
67
  - app/components/flowbite/card/title.rb
68
+ - app/components/flowbite/input.rb
44
69
  - app/components/flowbite/input/checkbox.rb
45
70
  - app/components/flowbite/input/date.rb
71
+ - app/components/flowbite/input/date_time.rb
46
72
  - app/components/flowbite/input/email.rb
47
- - app/components/flowbite/input/field.rb
48
73
  - app/components/flowbite/input/file.rb
49
74
  - app/components/flowbite/input/hint.rb
50
75
  - app/components/flowbite/input/label.rb
@@ -60,6 +85,7 @@ files:
60
85
  - app/components/flowbite/input_field/checkbox.html.erb
61
86
  - app/components/flowbite/input_field/checkbox.rb
62
87
  - app/components/flowbite/input_field/date.rb
88
+ - app/components/flowbite/input_field/date_time.rb
63
89
  - app/components/flowbite/input_field/email.rb
64
90
  - app/components/flowbite/input_field/file.rb
65
91
  - app/components/flowbite/input_field/input_field.html.erb
@@ -73,16 +99,25 @@ files:
73
99
  - app/components/flowbite/input_field/textarea.rb
74
100
  - app/components/flowbite/input_field/url.rb
75
101
  - app/components/flowbite/link.rb
102
+ - app/components/flowbite/sidebar.rb
103
+ - app/components/flowbite/sidebar/item.rb
104
+ - app/components/flowbite/sidebar/navigation.rb
76
105
  - app/components/flowbite/style.rb
77
106
  - app/components/flowbite/styles.rb
107
+ - app/components/flowbite/toast.rb
108
+ - app/components/flowbite/toast/icon.html.erb
109
+ - app/components/flowbite/toast/icon.rb
110
+ - app/components/flowbite/toast/toast.html.erb
78
111
  - lib/flowbite/components.rb
79
112
  - lib/flowbite/components/engine.rb
80
113
  - lib/flowbite/components/version.rb
81
- homepage: https://github.com/substancelab/flowbite-components
114
+ - lib/yard/flowbite_viewcomponent.rb
115
+ homepage: https://flowbite-components.substancelab.com
82
116
  licenses: []
83
117
  metadata:
84
118
  allowed_push_host: https://rubygems.org/
85
- homepage_uri: https://github.com/substancelab/flowbite-components
119
+ documentation_uri: https://flowbite-components.substancelab.com/docs
120
+ homepage_uri: https://flowbite-components.substancelab.com
86
121
  source_code_uri: https://github.com/substancelab/flowbite-components
87
122
  changelog_uri: https://github.com/substancelab/flowbite-components/blob/main/CHANGELOG.md
88
123
  rdoc_options: []
@@ -100,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
135
  - !ruby/object:Gem::Version
101
136
  version: '0'
102
137
  requirements: []
103
- rubygems_version: 3.6.9
138
+ rubygems_version: 4.0.6
104
139
  specification_version: 4
105
140
  summary: ViewComponents using the Flowbite design system
106
141
  test_files: []
@@ -1,126 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Flowbite
4
- module Input
5
- # The indivdual input component for use in forms without labels or error
6
- # messages.
7
- #
8
- # Use this when you want to render an input field on its own without any
9
- # surrounding elements, ie as a building block in more complex input
10
- # components.
11
- #
12
- # To render a complete input field with labels and error messages, use
13
- # `Flowbite::InputField` instead.
14
- class Field < ViewComponent::Base
15
- SIZES = {
16
- sm: ["px-2.5", "py-2", "text-sm"],
17
- default: ["px-3", "py-2.5", "text-sm"],
18
- lg: ["px-3.5", "py-3", "text-base"]
19
- }.freeze
20
-
21
- STATES = [
22
- DEFAULT = :default,
23
- DISABLED = :disabled,
24
- ERROR = :error
25
- ].freeze
26
-
27
- attr_reader :options, :size, :style
28
-
29
- class << self
30
- def classes(size: :default, state: :default, style: :default)
31
- style = styles.fetch(style)
32
- state_classes = style.fetch(state)
33
- state_classes + sizes.fetch(size)
34
- end
35
-
36
- # Returns the sizes this Field supports.
37
- #
38
- # This is effectively the SIZES constant, but provided as a method to
39
- # return the constant from the current class, not the superclass.
40
- #
41
- # @return [Hash] A hash mapping size names to their corresponding CSS
42
- # classes.
43
- def sizes
44
- const_get(:SIZES)
45
- end
46
-
47
- # rubocop:disable Layout/LineLength
48
- def styles
49
- Flowbite::Styles.from_hash(
50
- {
51
- default: {
52
- default: ["bg-neutral-secondary-medium", "border", "border-default-medium", "text-heading", "rounded-base", "focus:ring-brand", "focus:border-brand", "block", "w-full", "shadow-xs", "placeholder:text-body"],
53
- disabled: ["bg-neutral-secondary-medium", "border", "border-default-medium", "text-fg-disabled", "rounded-base", "focus:ring-brand", "focus:border-brand", "block", "w-full", "shadow-xs", "cursor-not-allowed", "placeholder:text-fg-disabled"],
54
- error: ["bg-danger-soft", "border", "border-danger-subtle", "text-fg-danger-strong", "rounded-base", "focus:ring-danger", "focus:border-danger", "block", "w-full", "shadow-xs", "placeholder:text-fg-danger-strong"]
55
- }
56
- }.freeze
57
- )
58
- end
59
- # rubocop:enable Layout/LineLength
60
- end
61
-
62
- def initialize(attribute:, form:, class: nil, disabled: false, options: {}, size: :default)
63
- @attribute = attribute
64
- @class = Array.wrap(binding.local_variable_get(:class))
65
- @disabled = disabled
66
- @form = form
67
- @options = options || {}
68
- @object = form.object
69
- @size = size
70
- end
71
-
72
- # Returns the HTML to use for the actual input field element.
73
- def call
74
- @form.send(
75
- input_field_type,
76
- @attribute,
77
- **input_options
78
- )
79
- end
80
-
81
- # Returns the CSS classes to apply to the input field
82
- def classes
83
- self.class.classes(size: size, state: state) + @class
84
- end
85
-
86
- # Returns the name of the method used to generate HTML for the input field
87
- def input_field_type
88
- :text_field
89
- end
90
-
91
- protected
92
-
93
- # Returns true if the field is disabled
94
- def disabled?
95
- !!@disabled
96
- end
97
-
98
- # Returns true if the object has errors. Returns false if there is no
99
- # object.
100
- #
101
- # @return [Boolean] true if there are errors, false otherwise.
102
- def errors?
103
- return false unless @object
104
-
105
- @object.errors.include?(@attribute.intern)
106
- end
107
-
108
- private
109
-
110
- # Returns the options argument for the input field
111
- def input_options
112
- {
113
- class: classes,
114
- disabled: disabled?
115
- }.merge(options)
116
- end
117
-
118
- def state
119
- return DISABLED if disabled?
120
- return ERROR if errors?
121
-
122
- DEFAULT
123
- end
124
- end
125
- end
126
- end