|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +class Views::Docs::Alert < Views::Base |
| 4 | + def view_template |
| 5 | + component = "Alert" |
| 6 | + div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do |
| 7 | + render Docs::Header.new(title: "Alert", description: "Displays a callout for user attention.") |
| 8 | + |
| 9 | + Heading(level: 2) { "Usage" } |
| 10 | + |
| 11 | + render Docs::VisualCodeExample.new(title: "Example", context: self) do |
| 12 | + <<~RUBY |
| 13 | + Alert do |
| 14 | + rocket_icon |
| 15 | + AlertTitle { "Pro tip" } |
| 16 | + AlertDescription { "With RubyUI you'll ship faster." } |
| 17 | + end |
| 18 | + RUBY |
| 19 | + end |
| 20 | + |
| 21 | + render Docs::VisualCodeExample.new(title: "Without Icon", context: self) do |
| 22 | + <<~RUBY |
| 23 | + Alert do |
| 24 | + AlertTitle { "Pro tip" } |
| 25 | + AlertDescription { "Simply, don't include an icon and your alert will look like this." } |
| 26 | + end |
| 27 | + RUBY |
| 28 | + end |
| 29 | + |
| 30 | + render Docs::VisualCodeExample.new(title: "Warning", context: self) do |
| 31 | + <<~RUBY |
| 32 | + Alert(variant: :warning) do |
| 33 | + info_icon |
| 34 | + AlertTitle { "Ship often" } |
| 35 | + AlertDescription { "Shipping is good, your users will thank you for it." } |
| 36 | + end |
| 37 | + RUBY |
| 38 | + end |
| 39 | + |
| 40 | + render Docs::VisualCodeExample.new(title: "Destructive", context: self) do |
| 41 | + <<~RUBY |
| 42 | + Alert(variant: :destructive) do |
| 43 | + alert_icon |
| 44 | + AlertTitle { "Oopsie daisy!" } |
| 45 | + AlertDescription { "Your design system is non-existent." } |
| 46 | + end |
| 47 | + RUBY |
| 48 | + end |
| 49 | + |
| 50 | + render Docs::VisualCodeExample.new(title: "Success", context: self) do |
| 51 | + <<~RUBY |
| 52 | + Alert(variant: :success) do |
| 53 | + check_icon |
| 54 | + AlertTitle { "Installation successful" } |
| 55 | + AlertDescription { "You're all set to start using RubyUI in your application." } |
| 56 | + end |
| 57 | + RUBY |
| 58 | + end |
| 59 | + |
| 60 | + render Components::ComponentSetup::Tabs.new(component_name: component) |
| 61 | + |
| 62 | + render Docs::ComponentsTable.new(component_files(component)) |
| 63 | + end |
| 64 | + end |
| 65 | + |
| 66 | + private |
| 67 | + |
| 68 | + def rocket_icon |
| 69 | + svg( |
| 70 | + xmlns: "http://www.w3.org/2000/svg", |
| 71 | + viewbox: "0 0 24 24", |
| 72 | + fill: "currentColor", |
| 73 | + class: "w-5 h-5" |
| 74 | + ) do |s| |
| 75 | + s.path( |
| 76 | + fill_rule: "evenodd", |
| 77 | + d: |
| 78 | + "M9.315 7.584C12.195 3.883 16.695 1.5 21.75 1.5a.75.75 0 01.75.75c0 5.056-2.383 9.555-6.084 12.436A6.75 6.75 0 019.75 22.5a.75.75 0 01-.75-.75v-4.131A15.838 15.838 0 016.382 15H2.25a.75.75 0 01-.75-.75 6.75 6.75 0 017.815-6.666zM15 6.75a2.25 2.25 0 100 4.5 2.25 2.25 0 000-4.5z", |
| 79 | + clip_rule: "evenodd" |
| 80 | + ) |
| 81 | + s.path( |
| 82 | + d: |
| 83 | + "M5.26 17.242a.75.75 0 10-.897-1.203 5.243 5.243 0 00-2.05 5.022.75.75 0 00.625.627 5.243 5.243 0 005.022-2.051.75.75 0 10-1.202-.897 3.744 3.744 0 01-3.008 1.51c0-1.23.592-2.323 1.51-3.008z" |
| 84 | + ) |
| 85 | + end |
| 86 | + end |
| 87 | + |
| 88 | + def alert_icon |
| 89 | + svg( |
| 90 | + xmlns: "http://www.w3.org/2000/svg", |
| 91 | + viewbox: "0 0 24 24", |
| 92 | + fill: "currentColor", |
| 93 | + class: "w-5 h-5" |
| 94 | + ) do |s| |
| 95 | + s.path( |
| 96 | + fill_rule: "evenodd", |
| 97 | + d: |
| 98 | + "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z", |
| 99 | + clip_rule: "evenodd" |
| 100 | + ) |
| 101 | + end |
| 102 | + end |
| 103 | + |
| 104 | + def info_icon |
| 105 | + svg( |
| 106 | + xmlns: "http://www.w3.org/2000/svg", |
| 107 | + viewbox: "0 0 24 24", |
| 108 | + fill: "currentColor", |
| 109 | + class: "w-5 h-5" |
| 110 | + ) do |s| |
| 111 | + s.path( |
| 112 | + fill_rule: "evenodd", |
| 113 | + d: |
| 114 | + "M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm8.706-1.442c1.146-.573 2.437.463 2.126 1.706l-.709 2.836.042-.02a.75.75 0 01.67 1.34l-.04.022c-1.147.573-2.438-.463-2.127-1.706l.71-2.836-.042.02a.75.75 0 11-.671-1.34l.041-.022zM12 9a.75.75 0 100-1.5.75.75 0 000 1.5z", |
| 115 | + clip_rule: "evenodd" |
| 116 | + ) |
| 117 | + end |
| 118 | + end |
| 119 | + |
| 120 | + def check_icon |
| 121 | + svg( |
| 122 | + xmlns: "http://www.w3.org/2000/svg", |
| 123 | + viewbox: "0 0 24 24", |
| 124 | + fill: "currentColor", |
| 125 | + class: "w-5 h-5" |
| 126 | + ) do |s| |
| 127 | + s.path( |
| 128 | + fill_rule: "evenodd", |
| 129 | + d: |
| 130 | + "M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z", |
| 131 | + clip_rule: "evenodd" |
| 132 | + ) |
| 133 | + end |
| 134 | + end |
| 135 | +end |
0 commit comments