kiso 0.1.0.pre
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 +7 -0
- data/CHANGELOG.md +27 -0
- data/MIT-LICENSE +20 -0
- data/README.md +117 -0
- data/Rakefile +5 -0
- data/app/assets/fonts/kiso/GeistMonoVF.woff2 +0 -0
- data/app/assets/fonts/kiso/GeistVF.woff2 +0 -0
- data/app/assets/fonts/kiso/OFL.txt +93 -0
- data/app/assets/tailwind/kiso/engine.css +32 -0
- data/app/helpers/kiso/component_helper.rb +47 -0
- data/app/helpers/kiso/icon_helper.rb +48 -0
- data/app/views/kiso/components/_alert.html.erb +8 -0
- data/app/views/kiso/components/_badge.html.erb +7 -0
- data/app/views/kiso/components/_button.html.erb +19 -0
- data/app/views/kiso/components/_card.html.erb +7 -0
- data/app/views/kiso/components/_empty_state.html.erb +7 -0
- data/app/views/kiso/components/_separator.html.erb +7 -0
- data/app/views/kiso/components/_stats_card.html.erb +7 -0
- data/app/views/kiso/components/_stats_grid.html.erb +7 -0
- data/app/views/kiso/components/_table.html.erb +8 -0
- data/app/views/kiso/components/alert/_description.html.erb +7 -0
- data/app/views/kiso/components/alert/_title.html.erb +7 -0
- data/app/views/kiso/components/card/_content.html.erb +7 -0
- data/app/views/kiso/components/card/_description.html.erb +7 -0
- data/app/views/kiso/components/card/_footer.html.erb +7 -0
- data/app/views/kiso/components/card/_header.html.erb +7 -0
- data/app/views/kiso/components/card/_title.html.erb +7 -0
- data/app/views/kiso/components/empty_state/_content.html.erb +7 -0
- data/app/views/kiso/components/empty_state/_description.html.erb +7 -0
- data/app/views/kiso/components/empty_state/_header.html.erb +7 -0
- data/app/views/kiso/components/empty_state/_media.html.erb +7 -0
- data/app/views/kiso/components/empty_state/_title.html.erb +7 -0
- data/app/views/kiso/components/stats_card/_description.html.erb +7 -0
- data/app/views/kiso/components/stats_card/_header.html.erb +7 -0
- data/app/views/kiso/components/stats_card/_label.html.erb +7 -0
- data/app/views/kiso/components/stats_card/_value.html.erb +7 -0
- data/app/views/kiso/components/table/_body.html.erb +7 -0
- data/app/views/kiso/components/table/_caption.html.erb +7 -0
- data/app/views/kiso/components/table/_cell.html.erb +7 -0
- data/app/views/kiso/components/table/_footer.html.erb +7 -0
- data/app/views/kiso/components/table/_head.html.erb +7 -0
- data/app/views/kiso/components/table/_header.html.erb +7 -0
- data/app/views/kiso/components/table/_row.html.erb +7 -0
- data/lib/kiso/cli/base.rb +37 -0
- data/lib/kiso/cli/icons.rb +6 -0
- data/lib/kiso/cli/main.rb +14 -0
- data/lib/kiso/cli/make.rb +369 -0
- data/lib/kiso/cli.rb +14 -0
- data/lib/kiso/engine.rb +26 -0
- data/lib/kiso/themes/alert.rb +65 -0
- data/lib/kiso/themes/badge.rb +66 -0
- data/lib/kiso/themes/button.rb +90 -0
- data/lib/kiso/themes/card.rb +44 -0
- data/lib/kiso/themes/empty_state.rb +42 -0
- data/lib/kiso/themes/separator.rb +17 -0
- data/lib/kiso/themes/stats_card.rb +57 -0
- data/lib/kiso/themes/table.rb +48 -0
- data/lib/kiso/version.rb +3 -0
- data/lib/kiso.rb +17 -0
- metadata +175 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4cd911512ec3d322db2ec1fd6ff2a24660fbc28e654424e710007e77a2e1317b
|
|
4
|
+
data.tar.gz: 8506e424c434844d10dd1dd7899ace376a65119b22e4602ea1ded3280ea85e86
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ffa23334590c70c3576bba3f3cbab806d4965d1c673e12652f1c976f3a213d02a88fa568a2773d62a484eae7af9a4a62b018c3eed8fd04ecb383f7e122274b0f
|
|
7
|
+
data.tar.gz: 371226d21fc79972ff6b7fc222f59b7fa81a5a3fc660cc6f73bb2bfc5986a22ba3200d05a360551c249583b33930f0370e899bb6af3bd8497335da4d80eddd39
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0.pre] - 2026-02-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Core engine with `kiso()` component helper and `component_tag` builder
|
|
15
|
+
- `class_variants` + `tailwind_merge` integration for variant definitions
|
|
16
|
+
- Theme CSS with 7 palettes, surface tokens, and dark mode
|
|
17
|
+
- Badge component (color × variant × size, pill shape, SVG handling)
|
|
18
|
+
- Alert component (color × variant, CSS Grid layout, title/description sub-parts)
|
|
19
|
+
- Button component (6 variants, smart tag, 5 sizes, icon support)
|
|
20
|
+
- Card component (3 variants, 6 sub-parts, shadcn gap-6/py-6 spacing)
|
|
21
|
+
- Separator component (horizontal/vertical, decorative prop)
|
|
22
|
+
- Empty State component (5 sub-parts, media variant)
|
|
23
|
+
- Lookbook component previews
|
|
24
|
+
- Bridgetown documentation site
|
|
25
|
+
|
|
26
|
+
[Unreleased]: https://github.com/steveclarke/kiso/compare/v0.1.0.pre...HEAD
|
|
27
|
+
[0.1.0.pre]: https://github.com/steveclarke/kiso/releases/tag/v0.1.0.pre
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright Stephen Clarke
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Kiso 基礎
|
|
2
|
+
|
|
3
|
+
UI components for Rails. Built on ERB, Tailwind CSS, and Hotwire.
|
|
4
|
+
|
|
5
|
+
Add one gem and get badges, buttons, cards, alerts, and more. They all work with screen readers and dark mode. The look follows [shadcn/ui](https://ui.shadcn.com).
|
|
6
|
+
|
|
7
|
+
No React. No extra build step. Just ERB with [class_variants](https://github.com/avo-hq/class_variants) for styling.
|
|
8
|
+
|
|
9
|
+
Icons come from the [kiso-icons](https://github.com/steveclarke/kiso-icons) gem, which is bundled in.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
# Gemfile
|
|
15
|
+
gem "kiso"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bundle install
|
|
20
|
+
bin/rails generate kiso:install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Use the `kiso()` helper to render components:
|
|
26
|
+
|
|
27
|
+
```erb
|
|
28
|
+
<%= kiso(:badge, variant: :primary) { "Active" } %>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Components are made of small parts. A card has a header, title, content, and footer:
|
|
32
|
+
|
|
33
|
+
```erb
|
|
34
|
+
<%= kiso(:card) do %>
|
|
35
|
+
<%= kiso(:card, :header) do %>
|
|
36
|
+
<%= kiso(:card, :title, text: "Members") %>
|
|
37
|
+
<% end %>
|
|
38
|
+
<%= kiso(:card, :content) do %>
|
|
39
|
+
...
|
|
40
|
+
<% end %>
|
|
41
|
+
<% end %>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Data attributes work on any HTML element too:
|
|
45
|
+
|
|
46
|
+
```erb
|
|
47
|
+
<%= f.submit "Save", data: { component: "button", variant: "primary" } %>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## How it works
|
|
51
|
+
|
|
52
|
+
Each component has two parts:
|
|
53
|
+
|
|
54
|
+
1. **A theme file** in `lib/kiso/themes/` — sets up variants, sizes, and colors
|
|
55
|
+
2. **An ERB partial** in `app/views/kiso/components/` — reads the theme and renders HTML
|
|
56
|
+
|
|
57
|
+
Colors use tokens like `bg-primary` and `text-muted`. They switch on their own in dark mode. No `dark:` classes needed.
|
|
58
|
+
|
|
59
|
+
## Design principles
|
|
60
|
+
|
|
61
|
+
1. **Native HTML first.** Use `<dialog>`, `[popover]`, `<details>` before adding JavaScript.
|
|
62
|
+
2. **Build from small parts.** Card = Header + Title + Content + Footer.
|
|
63
|
+
3. **ERB is enough.** Use strict locals and `yield` for blocks.
|
|
64
|
+
4. **Tailwind classes in ERB.** CSS files only hold transitions and pseudo-states.
|
|
65
|
+
5. **Theme with tokens.** Names like `primary` map to real colors. They flip in dark mode.
|
|
66
|
+
6. **Works with Turbo.** Use them in Turbo Frames and Streams.
|
|
67
|
+
7. **Stimulus only when needed.** Native HTML handles the basics. Stimulus adds the rest.
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git clone --recurse-submodules https://github.com/steveclarke/kiso.git
|
|
73
|
+
cd kiso
|
|
74
|
+
bundle install
|
|
75
|
+
bin/dev
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This starts [Lookbook](https://lookbook.build) on port 4001 with a Tailwind watcher. Open [http://localhost:4001/lookbook](http://localhost:4001/lookbook) to browse previews.
|
|
79
|
+
|
|
80
|
+
Cloned without `--recurse-submodules`? Run `bin/vendor init` to fetch the vendor repos.
|
|
81
|
+
|
|
82
|
+
Run tests:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
bundle exec rake test # all tests
|
|
86
|
+
bundle exec standardrb # lint
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) to help out.
|
|
90
|
+
|
|
91
|
+
### Project layout
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
app/views/kiso/components/ ERB partials
|
|
95
|
+
lib/kiso/themes/ Theme files (class_variants)
|
|
96
|
+
app/helpers/kiso/ component_tag, kiso() helpers
|
|
97
|
+
app/assets/stylesheets/kiso/ CSS (only transitions and pseudo-states)
|
|
98
|
+
test/components/previews/ Lookbook previews
|
|
99
|
+
test/dummy/ Dev Rails app
|
|
100
|
+
vendor/shadcn-ui/ Layout reference (git submodule)
|
|
101
|
+
vendor/nuxt-ui/ Theme reference (git submodule)
|
|
102
|
+
docs/ Docs site (Bridgetown)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Requirements
|
|
106
|
+
|
|
107
|
+
- Ruby >= 3.3
|
|
108
|
+
- Rails >= 8.0
|
|
109
|
+
- [tailwindcss-rails](https://github.com/rails/tailwindcss-rails)
|
|
110
|
+
|
|
111
|
+
## Status
|
|
112
|
+
|
|
113
|
+
Early development. See [VISION.md](VISION.md) for the roadmap and full component list.
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT License. See [MIT-LICENSE](MIT-LICENSE).
|
data/Rakefile
ADDED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://openfontlicense.org
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* Kiso Engine CSS — imported by host apps via tailwindcss-rails engine bundling.
|
|
2
|
+
Component CSS files go here for transitions, animations, and pseudo-states
|
|
3
|
+
that are awkward to express in ERB. Most styling lives in Ruby theme modules
|
|
4
|
+
(lib/kiso/themes/) as computed Tailwind classes. */
|
|
5
|
+
|
|
6
|
+
/* === Geist Font (by Vercel) ===
|
|
7
|
+
Self-hosted variable fonts — no CDN dependency.
|
|
8
|
+
Licensed under the SIL Open Font License (see OFL.txt).
|
|
9
|
+
Host apps can override --font-sans / --font-mono in their own @theme block. */
|
|
10
|
+
|
|
11
|
+
@font-face {
|
|
12
|
+
font-family: "Geist";
|
|
13
|
+
font-style: normal;
|
|
14
|
+
font-weight: 100 900;
|
|
15
|
+
font-display: swap;
|
|
16
|
+
src: url("/kiso/GeistVF.woff2") format("woff2");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@font-face {
|
|
20
|
+
font-family: "Geist Mono";
|
|
21
|
+
font-style: normal;
|
|
22
|
+
font-weight: 100 900;
|
|
23
|
+
font-display: swap;
|
|
24
|
+
src: url("/kiso/GeistMonoVF.woff2") format("woff2");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Set Geist as the default sans and mono fonts.
|
|
28
|
+
Host apps can override by redefining --font-sans / --font-mono. */
|
|
29
|
+
@theme inline {
|
|
30
|
+
--font-sans: "Geist", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
31
|
+
--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
32
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Kiso
|
|
2
|
+
module ComponentHelper
|
|
3
|
+
# Renders a component element with data-attribute API.
|
|
4
|
+
#
|
|
5
|
+
# component_tag(:span, :badge, variant: :primary, size: :md) { "Active" }
|
|
6
|
+
# # => <span data-component="badge" data-variant="primary" data-size="md">Active</span>
|
|
7
|
+
#
|
|
8
|
+
# component_tag(:div, :card, part: :header) { ... }
|
|
9
|
+
# # => <div data-card-part="header">...</div>
|
|
10
|
+
#
|
|
11
|
+
def component_tag(element, component, variant: nil, size: nil, part: nil, **options, &block)
|
|
12
|
+
data = options.delete(:data) || {}
|
|
13
|
+
|
|
14
|
+
if part
|
|
15
|
+
data[:"#{component}-part"] = part
|
|
16
|
+
else
|
|
17
|
+
data[:component] = component
|
|
18
|
+
data[:variant] = variant if variant
|
|
19
|
+
data[:size] = size if size
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
options[:data] = data
|
|
23
|
+
|
|
24
|
+
content_tag(element, **options, &block)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Renders a Kiso component partial.
|
|
28
|
+
#
|
|
29
|
+
# kiso(:badge, variant: :success) { "Active" }
|
|
30
|
+
# kiso(:card, :header) { ... }
|
|
31
|
+
# kiso(:badge, collection: @statuses)
|
|
32
|
+
#
|
|
33
|
+
def kiso(component, part = nil, collection: nil, **kwargs, &block)
|
|
34
|
+
path = if part
|
|
35
|
+
"kiso/components/#{component}/#{part}"
|
|
36
|
+
else
|
|
37
|
+
"kiso/components/#{component}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
if collection
|
|
41
|
+
render partial: path, collection: collection, **kwargs, &block
|
|
42
|
+
else
|
|
43
|
+
render path, **kwargs, &block
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "tailwind_merge"
|
|
4
|
+
|
|
5
|
+
module Kiso
|
|
6
|
+
module IconHelper
|
|
7
|
+
SIZE_PRESETS = {
|
|
8
|
+
xs: "size-3",
|
|
9
|
+
sm: "size-4",
|
|
10
|
+
md: "size-5",
|
|
11
|
+
lg: "size-6",
|
|
12
|
+
xl: "size-8"
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
15
|
+
BASE_CLASSES = "shrink-0"
|
|
16
|
+
|
|
17
|
+
# Renders an inline SVG icon with Tailwind classes.
|
|
18
|
+
#
|
|
19
|
+
# kiso_icon("lucide:check")
|
|
20
|
+
# kiso_icon("check") # uses default set (lucide)
|
|
21
|
+
# kiso_icon("check", size: :md) # size preset (standalone use)
|
|
22
|
+
# kiso_icon("check", class: "text-success") # extra classes
|
|
23
|
+
# kiso_icon("check", aria: { label: "Done" }) # accessible icon
|
|
24
|
+
#
|
|
25
|
+
# Size defaults to nil so parent components (Button, Alert, Badge) can
|
|
26
|
+
# control icon sizing via CSS selectors like [&_svg]:size-4.
|
|
27
|
+
# Pass an explicit size: for standalone icons outside components.
|
|
28
|
+
#
|
|
29
|
+
def kiso_icon(name, size: nil, **options)
|
|
30
|
+
css_classes = options.delete(:class) || ""
|
|
31
|
+
size_class = size ? SIZE_PRESETS.fetch(size, nil) : nil
|
|
32
|
+
merged = merge_icon_classes(BASE_CLASSES, size_class, css_classes)
|
|
33
|
+
|
|
34
|
+
kiso_icon_tag(name, class: merged, **options)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def merge_icon_classes(*parts)
|
|
40
|
+
combined = parts.reject { |p| p.nil? || p.to_s.empty? }.join(" ")
|
|
41
|
+
icon_class_merger.merge(combined)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def icon_class_merger
|
|
45
|
+
@icon_class_merger ||= TailwindMerge::Merger.new
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%# locals: (color: :primary, variant: :soft, css_classes: "", **component_options) %>
|
|
2
|
+
<%= content_tag :div,
|
|
3
|
+
role: :alert,
|
|
4
|
+
class: Kiso::Themes::Alert.render(color: color, variant: variant, class: css_classes),
|
|
5
|
+
data: { component: :alert },
|
|
6
|
+
**component_options do %>
|
|
7
|
+
<%= yield %>
|
|
8
|
+
<% end %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%# locals: (color: :primary, variant: :soft, size: :md, css_classes: "", **component_options) %>
|
|
2
|
+
<%= content_tag :span,
|
|
3
|
+
class: Kiso::Themes::Badge.render(color: color, variant: variant, size: size, class: css_classes),
|
|
4
|
+
data: { component: :badge },
|
|
5
|
+
**component_options do %>
|
|
6
|
+
<%= yield %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<%# locals: (color: :primary, variant: :solid, size: :md, block: false,
|
|
2
|
+
type: :button, href: nil, disabled: false,
|
|
3
|
+
css_classes: "", **component_options) %>
|
|
4
|
+
<% tag_name = href.present? ? :a : :button
|
|
5
|
+
if tag_name == :a
|
|
6
|
+
component_options[:href] = href
|
|
7
|
+
component_options[:"aria-disabled"] = true if disabled
|
|
8
|
+
else
|
|
9
|
+
component_options[:type] = type
|
|
10
|
+
component_options[:disabled] = true if disabled
|
|
11
|
+
end %>
|
|
12
|
+
<%= content_tag tag_name,
|
|
13
|
+
class: Kiso::Themes::Button.render(
|
|
14
|
+
color: color, variant: variant, size: size, block: block,
|
|
15
|
+
class: css_classes),
|
|
16
|
+
data: { component: :button },
|
|
17
|
+
**component_options do %>
|
|
18
|
+
<%= yield %>
|
|
19
|
+
<% end %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%# locals: (orientation: :horizontal, decorative: true, css_classes: "", **component_options) %>
|
|
2
|
+
<%= tag.div(
|
|
3
|
+
role: (decorative ? "none" : "separator"),
|
|
4
|
+
aria: (decorative ? {} : { orientation: orientation }),
|
|
5
|
+
class: Kiso::Themes::Separator.render(orientation: orientation, class: css_classes),
|
|
6
|
+
data: { component: :separator },
|
|
7
|
+
**component_options) %>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%# locals: (css_classes: "", **component_options) %>
|
|
2
|
+
<div class="relative w-full overflow-x-auto" data-component="table" data-table-part="container">
|
|
3
|
+
<%= content_tag :table,
|
|
4
|
+
class: Kiso::Themes::Table.render(class: css_classes),
|
|
5
|
+
**component_options do %>
|
|
6
|
+
<%= yield %>
|
|
7
|
+
<% end %>
|
|
8
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%# locals: (css_classes: "", **component_options) %>
|
|
2
|
+
<%= content_tag :div,
|
|
3
|
+
class: Kiso::Themes::EmptyStateDescription.render(class: css_classes),
|
|
4
|
+
data: { component: :empty_state, empty_state_part: :description },
|
|
5
|
+
**component_options do %>
|
|
6
|
+
<%= yield %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%# locals: (variant: :default, css_classes: "", **component_options) %>
|
|
2
|
+
<%= content_tag :div,
|
|
3
|
+
class: Kiso::Themes::EmptyStateMedia.render(variant: variant, class: css_classes),
|
|
4
|
+
data: { component: :empty_state, empty_state_part: :media },
|
|
5
|
+
**component_options do %>
|
|
6
|
+
<%= yield %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%# locals: (css_classes: "", **component_options) %>
|
|
2
|
+
<%= content_tag :div,
|
|
3
|
+
class: Kiso::Themes::StatsCardDescription.render(class: css_classes),
|
|
4
|
+
data: { component: :stats_card, stats_card_part: :description },
|
|
5
|
+
**component_options do %>
|
|
6
|
+
<%= yield %>
|
|
7
|
+
<% end %>
|