essence 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b698fdfbf94b34b4afa01e1c6f38a2e9ac2feca00f34166c0acead4c4e6c8e40
4
- data.tar.gz: b11e693d29dbc9bd6763725692570bffb8879cafb32967cc1c34a2fbc5c65881
3
+ metadata.gz: c9a6970b18d2b7b5546ed98b54b5a782b74cbd92b379f69b996643416f604bd8
4
+ data.tar.gz: e1fedc61962792961d2ae47ecb01f7fe77c6c312ec2efb0987a4faa5b8e88cf1
5
5
  SHA512:
6
- metadata.gz: b95a0636aca009728061fc524f93bfeacf2728aa846e7e6ff7afa8918ba99ce1a47ba80ef8bc44863d982c0cb8cc1ef760f61f9c367b9cddd9beda463de5798c
7
- data.tar.gz: 371fb23359faf1f9e5835394c2fea1952813d7f43bf0f008704b641dca2d50faa2463c371869d1511a8625a22b9416ac8d2c3b59f09ceae36ca1c1e6fc865d29
6
+ metadata.gz: 22926d9d79c1ed96f02d48791b6badd99d032b7c23edd93d0159c9a5b2c275606f5570b8881543ed582066b3d7cd9187c94a2504ab3f6c97805e7f12d09cc1e7
7
+ data.tar.gz: 3d8816d4799f4e415ca1f7733202a914e1332579c2df95a24da7c3e0fca81039833b925a5df9f3625dce086c43f708a994c89525c4edc14e9da532f99a7e9a1f
data/README.md CHANGED
@@ -14,10 +14,10 @@ A simple, ergonomic and performant component library for Ruby applications.
14
14
 
15
15
  ### Features
16
16
 
17
- - Tailored components - Designed using flexibility in mind while streamlining the development process
18
- - Gorgeous simplicity - Essence empowers minimalistic user interface with purposeful accents
19
- - Geared for performance - Keep everything in one place. No spreadsheets or getting lost between tooling
20
- - Ergonomic approach - Essence is designed to be easy to use and understand
17
+ - Tailored components - Flexible by design while streamlining the development process
18
+ - Gorgeous simplicity - Empowers minimalistic user interface with purposeful accents
19
+ - Geared for performance - Built with performance in mind
20
+ - Ergonomic approach - Designed to be easy to use and understand
21
21
 
22
22
  ---
23
23
 
@@ -45,6 +45,7 @@ More information on about the installation can be found in the [documentation](h
45
45
 
46
46
  - [Mintis](https://mintis.app)
47
47
  - [Hansa](https://hansahq.com)
48
+ - [Oversee](https://github.com/primevise/oversee)
48
49
  - [Release Server](https://releaseserver.com)
49
50
  - [College Life Work](https://work.collegelife.co)
50
51
 
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Essence::Accordion < Essence::Essence
4
+ BASE = "group py-4"
5
+ TRIGGER_BASE = "cursor-pointer list-none flex items-center justify-between text-base font-medium"
6
+ CONTENT_BASE = "py-2 transform transition-all duration-500 not-open:-mt-4 opacity-0 group-open:opacity-100 group-open:mt-0 text-sm"
7
+ CHEVRON_BASE = "transform transition-all duration-300 rotate-90 group-open:-rotate-90 text-lg text-gray-700"
8
+
9
+ attr_reader :attributes
10
+
11
+ def initialize(**attributes)
12
+ super(**attributes)
13
+ @attributes[:class] = merge_classes([ BASE, @attributes[:class]])
14
+ end
15
+
16
+ def view_template(&)
17
+ details(class: "w-full group py-4", &) if block_given?
18
+ end
19
+
20
+ def trigger(**tattributes, &)
21
+ summary(class: merge_classes(TRIGGER_BASE, tattributes[:class])) do
22
+ p(class: "inline", &)
23
+ span(class: CHEVRON_BASE) { "›" }
24
+ end
25
+ end
26
+
27
+ def content(**cattributes, &)
28
+ p(class: merge_classes(CONTENT_BASE, cattributes[:class]), &)
29
+ end
30
+
31
+ private
32
+
33
+ def merge_classes(*classes)
34
+ TAILWIND_MERGER.merge([ *classes ].compact)
35
+ end
36
+ end
@@ -1,49 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Essence::Button < Essence::Essence
4
- BASE = "inline-flex items-center justify-center w-fit rounded-xs border border-transparent font-medium transition duration-150 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed hover:opacity-90"
3
+ class Essence::Avatar < Essence::Essence
4
+ BASE = "border border-transparent rounded-full bg-gray-100 aspect-square inline-flex items-center justify-center font-medium text-gray-700 overflow-hidden"
5
+
5
6
  SIZES = {
6
- none: "",
7
- xs: "text-[0.6rem] px-2 py-1.5 gap-1",
8
- sm: "text-xs px-3 py-2 gap-1.5",
9
- md: "text-sm px-4 py-2 gap-2",
10
- lg: "text-base px-6 py-2.5 gap-2.5",
11
- xl: "text-base px-8 py-3 gap-3"
12
- }
13
- KINDS = {
14
- primary: "text-white bg-indigo-500 hover:bg-indigo-500",
15
- secondary: "text-gray-700 bg-gray-100 hover:bg-gray-200",
16
- critical: "text-white bg-rose-500 hover:bg-rose-400",
17
- warning: "text-white bg-amber-500 hover:bg-amber-400",
18
- success: "text-white bg-emerald-500 hover:bg-emerald-400",
19
- info: "text-white bg-blue-500 hover:bg-blue-400",
20
- dark: "text-white bg-gray-900 hover:bg-gray-800",
21
- white: "text-gray-900 bg-white hover:bg-gray-200",
22
- ghost: "text-gray-900 bg-white hover:bg-gray-200 hover:text-gray-800"
7
+ sm: "size-6 text-[0.5rem]",
8
+ md: "size-8 text-xs",
9
+ lg: "size-12 text-sm"
23
10
  }
24
11
 
25
- attr_reader :size
26
- attr_reader :kind
27
12
  attr_reader :attributes
13
+ attr_reader :size
28
14
 
29
- def initialize(size: :md, kind: :primary, **attributes)
15
+ def initialize(size: :md, **attributes)
16
+ super(**attributes)
30
17
  @size = size
31
- @kind = kind
32
- @attributes = attributes
33
- @attributes[:class] = construct_classes(@attributes[:class])
18
+ @attributes[:class] = merge_classes([ BASE, SIZES[size], @attributes[:class]])
34
19
  end
35
20
 
36
21
  def view_template(&)
37
- element_tag(**attributes, &)
38
- end
39
-
40
- private
41
-
42
- def element_tag(...)
43
- attributes[:href] ? a(...) : button(...)
22
+ div(**attributes) do
23
+ img(src: attributes[:src], alt: attributes[:alt]) if attributes[:src]
24
+ yield if block_given?
25
+ end
44
26
  end
45
27
 
46
- def construct_classes(classes)
47
- TAILWIND_MERGER.merge([ BASE, SIZES[size], KINDS[kind], classes ].compact)
28
+ def fallback(**attrs, &)
29
+ div(**attrs, &)
48
30
  end
49
31
  end
@@ -1,31 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Essence::Avatar < Essence::Essence
4
- BASE = "border border-transparent rounded-full bg-gray-100 aspect-square inline-flex items-center justify-center font-medium text-gray-700"
3
+ class Essence::Badge < Essence::Essence
4
+ BASE = "inline-flex items-center justify-center w-fit rounded-full border border-transparent font-medium transition duration-150 hover:opacity-90"
5
5
  SIZES = {
6
- sm: "size-6 text-xs",
7
- md: "size-8 text-sm",
8
- lg: "size-12 text-base"
6
+ none: "",
7
+ sm: "text-[0.65rem] px-2 py-0.5 gap-1 min-w-8",
8
+ md: "text-xs px-2.5 py-1 gap-2 min-w-12",
9
+ lg: "text-sm px-4 py-1 gap-2 min-w-16"
10
+ }
11
+ KINDS = {
12
+ primary: "text-gray-900 border-gray-200",
13
+ success: "text-white bg-emerald-500",
14
+ critical: "text-white bg-rose-500",
15
+ warning: "text-white bg-amber-500",
16
+ info: "text-white bg-blue-500",
17
+ dark: "text-white bg-gray-900",
18
+ white: "text-gray-900 bg-white"
9
19
  }
10
20
 
11
- attr_reader :attributes
12
21
  attr_reader :size
22
+ attr_reader :kind
23
+ attr_reader :attributes
13
24
 
14
- def initialize(size: :md, **attributes)
25
+ def initialize(size: :md, kind: :primary, **attributes)
15
26
  @size = size
16
- @attributes = attributes
17
- @attributes[:class] = construct_classes(@attributes[:class])
27
+ @kind = kind
28
+ super(**attributes)
29
+ @attributes[:class] = merge_classes([ BASE, SIZES[size], KINDS[kind], @attributes[:class]])
18
30
  end
19
31
 
20
32
  def view_template(&)
21
33
  div(**attributes, &)
22
34
  end
23
-
24
- def fallback(**attrs, &)
25
- span(**attrs, &)
26
- end
27
-
28
- def construct_classes(classes)
29
- TAILWIND_MERGER.merge([ BASE, SIZES[size], classes ].compact)
30
- end
31
35
  end
@@ -1,21 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Essence::Badge < Essence::Essence
4
- BASE = "inline-flex items-center justify-center w-fit rounded-full border border-transparent font-medium transition duration-150 hover:opacity-90"
3
+ class Essence::Button < Essence::Essence
4
+ BASE = "inline-flex items-center justify-center w-fit rounded-xs border border-transparent font-medium transition duration-150 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed hover:opacity-90"
5
5
  SIZES = {
6
6
  none: "",
7
- sm: "text-[0.65rem] px-2 py-0.5 gap-1",
8
- md: "text-xs px-2.5 py-1 gap-2",
9
- lg: "text-sm px-4 py-1.5 gap-2"
7
+ xs: "text-[0.6rem] px-2 py-1.5 gap-1",
8
+ sm: "text-xs px-3 py-2 gap-1.5",
9
+ md: "text-sm px-4 py-2 gap-2",
10
+ lg: "text-base px-6 py-2.5 gap-2.5",
11
+ xl: "text-base px-8 py-3 gap-3"
10
12
  }
11
13
  KINDS = {
12
- primary: "text-gray-900 border-gray-200",
13
- success: "text-white bg-emerald-500",
14
- critical: "text-white bg-rose-500",
15
- warning: "text-white bg-amber-500",
16
- info: "text-white bg-blue-500",
17
- dark: "text-white bg-gray-900",
18
- white: "text-gray-900 bg-white"
14
+ primary: "text-white bg-indigo-500 hover:bg-indigo-500",
15
+ secondary: "text-gray-700 bg-gray-100 hover:bg-gray-200",
16
+ critical: "text-white bg-rose-500 hover:bg-rose-400",
17
+ warning: "text-white bg-amber-500 hover:bg-amber-400",
18
+ success: "text-white bg-emerald-500 hover:bg-emerald-400",
19
+ info: "text-white bg-blue-500 hover:bg-blue-400",
20
+ dark: "text-white bg-gray-900 hover:bg-gray-800",
21
+ white: "text-gray-900 bg-white hover:bg-gray-200",
22
+ ghost: "text-gray-900 hover:bg-gray-200 hover:text-gray-800"
19
23
  }
20
24
 
21
25
  attr_reader :size
@@ -25,18 +29,17 @@ class Essence::Badge < Essence::Essence
25
29
  def initialize(size: :md, kind: :primary, **attributes)
26
30
  @size = size
27
31
  @kind = kind
28
- @attributes = attributes
29
- @attributes[:class] = construct_classes(@attributes[:class])
32
+ super(**attributes)
33
+ @attributes[:class] = merge_classes([ BASE, SIZES[size], KINDS[kind], @attributes[:class]])
30
34
  end
31
35
 
32
36
  def view_template(&)
33
- div(**attributes, &)
37
+ element_tag(**attributes, &)
34
38
  end
35
39
 
36
40
  private
37
41
 
38
- def construct_classes(classes)
39
- TAILWIND_MERGER.merge([ BASE, SIZES[size], KINDS[kind], classes ].compact)
42
+ def element_tag(...)
43
+ attributes[:href] ? a(...) : button(...)
40
44
  end
41
-
42
45
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Essence::Dialog < Essence::Essence
4
+ BASE = ""
5
+
6
+ attr_reader :attributes
7
+
8
+ def initialize(**attributes)
9
+ super(**attributes)
10
+ @attributes[:class] = merge_classes([ BASE, @attributes[:class]])
11
+ end
12
+
13
+ def view_template(&)
14
+ dialog(**attributes) do
15
+ yield if block_given?
16
+ end
17
+ end
18
+
19
+ def footer(&)
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Essence::Dropdown < Essence::Essence
4
+ BASE = ""
5
+
6
+ attr_reader :attributes
7
+
8
+ def initialize(**attributes)
9
+ super(**attributes)
10
+ @attributes[:class] = merge_classes([ BASE, @attributes[:class]])
11
+ end
12
+
13
+ def view_template(&)
14
+ div(**attributes) do
15
+ yield if block_given?
16
+ end
17
+ end
18
+ end
@@ -6,13 +6,11 @@ class Essence::Essence < Phlex::HTML
6
6
  attr_reader :attributes
7
7
 
8
8
  def initialize(**attributes)
9
- @attributes = attributes
10
- @attributes[:class] = TAILWIND_MERGER.merge([self.class::CLASSES, @attributes[:class]]) if @attributes[:class]
9
+ @attributes = default_attributes.deep_merge(attributes)
11
10
  end
12
11
 
13
12
  private
14
13
 
15
- def default_attributes
16
- {}
17
- end
14
+ def default_attributes = {}
15
+ def merge_classes(*classes) = TAILWIND_MERGER.merge([ *classes ].compact)
18
16
  end
@@ -10,8 +10,8 @@ class Essence::Link < Essence::Essence
10
10
  attr_reader :attributes
11
11
 
12
12
  def initialize(kind: :regular, **attributes)
13
- @attributes = attributes
14
- @attributes[:class] = @attributes[:class] ? TAILWIND_MERGER.merge([ BASE, @attributes[:class] ]) : BASE
13
+ super(**attributes)
14
+ @attributes[:class] = merge_classes([ BASE, @attributes[:class]])
15
15
  end
16
16
 
17
17
  def view_template(&)
@@ -14,8 +14,8 @@ class Essence::Row < Essence::Essence
14
14
 
15
15
  def initialize(kind: :default, **attributes)
16
16
  @kind = kind
17
- @attributes = attributes
18
- @attributes[:class] = @attributes[:class] ? TAILWIND_MERGER.merge([ BASE, KINDS[kind], @attributes[:class] ]) : BASE
17
+ super(**attributes)
18
+ @attributes[:class] = merge_classes([ BASE, KINDS[kind], @attributes[:class]])
19
19
  end
20
20
 
21
21
  def view_template(&)
@@ -4,8 +4,8 @@ class Essence::Skeleton < Essence::Essence
4
4
  BASE = "animate-pulse bg-gray-200/55 rounded-xs"
5
5
 
6
6
  def initialize(**attributes)
7
- @attributes = attributes
8
- @attributes[:class] = @attributes[:class] ? TAILWIND_MERGER.merge([ BASE, @attributes[:class] ]) : BASE
7
+ super(**attributes)
8
+ @attributes[:class] = merge_classes([ BASE, @attributes[:class]])
9
9
  end
10
10
 
11
11
  def view_template(&)
@@ -1,3 +1,3 @@
1
1
  module Essence
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/essence.rb CHANGED
@@ -4,12 +4,14 @@ require "tailwind_merge"
4
4
 
5
5
  module Essence
6
6
  # Autoloading
7
- autoload :Component, "essence/components/component"
8
-
7
+ autoload :Accordion, "essence/components/accordion"
8
+ autoload :Avatar, "essence/components/avatar"
9
+ autoload :Badge, "essence/components/badge"
9
10
  autoload :Button, "essence/components/button"
11
+ # autoload :Essence, "essence/components/essence" # Base component
10
12
  autoload :Link, "essence/components/link"
11
- autoload :Skeleton, "essence/components/skeleton"
12
13
  autoload :Row, "essence/components/row"
14
+ autoload :Skeleton, "essence/components/skeleton"
13
15
 
14
16
  autoload :CLI, "essence/cli"
15
17
 
@@ -19,24 +21,26 @@ module Essence
19
21
  def self.component_class_names
20
22
  @component_class_names ||= {
21
23
  essence: "Essence::Essence",
22
- avataro: "Essence::Avatar",
24
+ accordion: "Essence::Accordion",
25
+ avatar: "Essence::Avatar",
23
26
  badge: "Essence::Badge",
24
27
  button: "Essence::Button",
25
28
  link: "Essence::Link",
26
- skeleton: "Essence::Skeleton",
27
29
  row: "Essence::Row",
30
+ skeleton: "Essence::Skeleton",
28
31
  }
29
32
  end
30
33
 
31
34
  def self.component_classes
32
35
  @components_classes ||= {
33
36
  essence: ::Essence::Essence,
37
+ accordion: ::Essence::Accordion,
34
38
  avatar: ::Essence::Avatar,
35
39
  badge: ::Essence::Badge,
36
40
  button: ::Essence::Button,
37
41
  link: ::Essence::Link,
38
- skeleton: ::Essence::Skeleton,
39
42
  row: ::Essence::Row,
43
+ skeleton: ::Essence::Skeleton,
40
44
  }
41
45
  end
42
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: essence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elvinas Predkelis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-12-22 00:00:00.000000000 Z
12
+ date: 2024-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-cli
@@ -74,9 +74,12 @@ files:
74
74
  - lib/essence/cli/add.rb
75
75
  - lib/essence/cli/install.rb
76
76
  - lib/essence/cli/version.rb
77
+ - lib/essence/components/accordion.rb
77
78
  - lib/essence/components/avatar.rb
78
79
  - lib/essence/components/badge.rb
79
80
  - lib/essence/components/button.rb
81
+ - lib/essence/components/dialog.rb
82
+ - lib/essence/components/dropdown.rb
80
83
  - lib/essence/components/essence.rb
81
84
  - lib/essence/components/link.rb
82
85
  - lib/essence/components/row.rb