|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +class Views::Docs::Button < Views::Base |
| 4 | + def view_template |
| 5 | + component = "Button" |
| 6 | + |
| 7 | + div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do |
| 8 | + render Docs::Header.new(title: "Button", description: "Displays a button or a component that looks like a button.") |
| 9 | + |
| 10 | + Heading(level: 2) { "Usage" } |
| 11 | + |
| 12 | + render Docs::VisualCodeExample.new(title: "Example", context: self) do |
| 13 | + <<~RUBY |
| 14 | + Button { "Button" } |
| 15 | + RUBY |
| 16 | + end |
| 17 | + |
| 18 | + render Docs::VisualCodeExample.new(title: "Primary", context: self) do |
| 19 | + <<~RUBY |
| 20 | + Button(variant: :primary) { "Primary" } |
| 21 | + RUBY |
| 22 | + end |
| 23 | + |
| 24 | + render Docs::VisualCodeExample.new(title: "Secondary", context: self) do |
| 25 | + <<~RUBY |
| 26 | + Button(variant: :secondary) { "Secondary" } |
| 27 | + RUBY |
| 28 | + end |
| 29 | + |
| 30 | + render Docs::VisualCodeExample.new(title: "Destructive", context: self) do |
| 31 | + <<~RUBY |
| 32 | + Button(variant: :destructive) { "Destructive" } |
| 33 | + RUBY |
| 34 | + end |
| 35 | + |
| 36 | + render Docs::VisualCodeExample.new(title: "Outline", context: self) do |
| 37 | + <<~RUBY |
| 38 | + Button(variant: :outline) { "Outline" } |
| 39 | + RUBY |
| 40 | + end |
| 41 | + |
| 42 | + render Docs::VisualCodeExample.new(title: "Ghost", context: self) do |
| 43 | + <<~RUBY |
| 44 | + Button(variant: :ghost) { "Ghost" } |
| 45 | + RUBY |
| 46 | + end |
| 47 | + |
| 48 | + render Docs::VisualCodeExample.new(title: "Link", context: self) do |
| 49 | + <<~RUBY |
| 50 | + Button(variant: :link) { "Link" } |
| 51 | + RUBY |
| 52 | + end |
| 53 | + |
| 54 | + render Docs::VisualCodeExample.new(title: "Disabled", context: self) do |
| 55 | + <<~RUBY |
| 56 | + Button(disabled: true) { "Disabled" } |
| 57 | + RUBY |
| 58 | + end |
| 59 | + |
| 60 | + render Docs::VisualCodeExample.new(title: "Aria Disabled", context: self) do |
| 61 | + <<~RUBY |
| 62 | + Button(aria: {disabled: "true"}) { "Aria Disabled" } |
| 63 | + RUBY |
| 64 | + end |
| 65 | + |
| 66 | + render Docs::VisualCodeExample.new(title: "Icon", context: self) do |
| 67 | + <<~RUBY |
| 68 | + Button(variant: :outline, icon: true) do |
| 69 | + svg( |
| 70 | + xmlns: "http://www.w3.org/2000/svg", |
| 71 | + viewbox: "0 0 20 20", |
| 72 | + fill: "currentColor", |
| 73 | + class: "w-5 h-5" |
| 74 | + ) do |s| |
| 75 | + s.path( |
| 76 | + fill_rule: "evenodd", |
| 77 | + d: |
| 78 | + "M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z", |
| 79 | + clip_rule: "evenodd" |
| 80 | + ) |
| 81 | + end |
| 82 | + end |
| 83 | + RUBY |
| 84 | + end |
| 85 | + |
| 86 | + render Docs::VisualCodeExample.new(title: "With Icon", context: self) do |
| 87 | + <<~RUBY |
| 88 | + Button(variant: :primary) do |
| 89 | + svg( |
| 90 | + xmlns: "http://www.w3.org/2000/svg", |
| 91 | + fill: "none", |
| 92 | + viewbox: "0 0 24 24", |
| 93 | + stroke_width: "1.5", |
| 94 | + stroke: "currentColor", |
| 95 | + class: "w-4 h-4 mr-2" |
| 96 | + ) do |s| |
| 97 | + s.path( |
| 98 | + stroke_linecap: "round", |
| 99 | + stroke_linejoin: "round", |
| 100 | + d: |
| 101 | + "M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75" |
| 102 | + ) |
| 103 | + end |
| 104 | + span { "Login with Email" } |
| 105 | + end |
| 106 | + RUBY |
| 107 | + end |
| 108 | + |
| 109 | + render Docs::VisualCodeExample.new(title: "With Icon", context: self) do |
| 110 | + <<~RUBY |
| 111 | + Button(variant: :primary, disabled: true) do |
| 112 | + svg( |
| 113 | + xmlns: "http://www.w3.org/2000/svg", |
| 114 | + viewbox: "0 0 20 20", |
| 115 | + fill: "currentColor", |
| 116 | + class: "w-4 h-4 mr-2 animate-spin" |
| 117 | + ) do |s| |
| 118 | + s.path( |
| 119 | + fill_rule: "evenodd", |
| 120 | + d: |
| 121 | + "M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z", |
| 122 | + clip_rule: "evenodd" |
| 123 | + ) |
| 124 | + end |
| 125 | + span { "Please wait" } |
| 126 | + end |
| 127 | + RUBY |
| 128 | + end |
| 129 | + |
| 130 | + render Docs::VisualCodeExample.new(title: "Submit", context: self) do |
| 131 | + <<~RUBY |
| 132 | + Button(variant: :primary, type: :submit) do |
| 133 | + span { "Submit application" } |
| 134 | + end |
| 135 | + RUBY |
| 136 | + end |
| 137 | + |
| 138 | + render Components::ComponentSetup::Tabs.new(component_name: component) |
| 139 | + |
| 140 | + render Docs::ComponentsTable.new(component_files(component)) |
| 141 | + end |
| 142 | + end |
| 143 | +end |
0 commit comments