|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +class Views::Docs::Message < Views::Base |
| 4 | + def view_template |
| 5 | + component = "Message" |
| 6 | + |
| 7 | + div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do |
| 8 | + render Docs::Header.new(title: "Message", description: "A chat message layout that pairs an avatar with bubbles, headers, and footers. Built on top of Avatar and Bubble.") |
| 9 | + |
| 10 | + Heading(level: 2) { "Usage" } |
| 11 | + |
| 12 | + render Docs::VisualCodeExample.new(title: "Conversation", context: self) do |
| 13 | + <<~RUBY |
| 14 | + div(class: "flex flex-col gap-6") do |
| 15 | + Message(align: :end) do |
| 16 | + MessageAvatar do |
| 17 | + Avatar(size: :sm) do |
| 18 | + AvatarFallback { "ME" } |
| 19 | + end |
| 20 | + end |
| 21 | + MessageContent do |
| 22 | + Bubble do |
| 23 | + BubbleContent { "Deploying to prod real quick." } |
| 24 | + end |
| 25 | + end |
| 26 | + end |
| 27 | +
|
| 28 | + Message do |
| 29 | + MessageAvatar do |
| 30 | + Avatar(size: :sm) do |
| 31 | + AvatarFallback { "R" } |
| 32 | + end |
| 33 | + end |
| 34 | + MessageContent do |
| 35 | + Bubble(variant: :muted) do |
| 36 | + BubbleContent { "It's 4:55 PM. On a Friday." } |
| 37 | + end |
| 38 | + end |
| 39 | + end |
| 40 | +
|
| 41 | + Message(align: :end) do |
| 42 | + MessageAvatar do |
| 43 | + Avatar(size: :sm) do |
| 44 | + AvatarFallback { "ME" } |
| 45 | + end |
| 46 | + end |
| 47 | + MessageContent do |
| 48 | + Bubble do |
| 49 | + BubbleContent { "It's a one-line change." } |
| 50 | + end |
| 51 | + MessageFooter { "Delivered" } |
| 52 | + end |
| 53 | + end |
| 54 | +
|
| 55 | + Message do |
| 56 | + MessageAvatar do |
| 57 | + Avatar(size: :sm) do |
| 58 | + AvatarFallback { "R" } |
| 59 | + end |
| 60 | + end |
| 61 | + MessageContent do |
| 62 | + BubbleGroup do |
| 63 | + Bubble(variant: :muted) do |
| 64 | + BubbleContent { "It's always a one-line change 😭." } |
| 65 | + end |
| 66 | + Bubble(variant: :muted) do |
| 67 | + BubbleContent { "Alright, let me take a look." } |
| 68 | + BubbleReactions(role: "img", aria_label: "Reaction: thumbs up") do |
| 69 | + span { "👍" } |
| 70 | + end |
| 71 | + end |
| 72 | + end |
| 73 | + end |
| 74 | + end |
| 75 | + end |
| 76 | + RUBY |
| 77 | + end |
| 78 | + |
| 79 | + Heading(level: 2) { "With header" } |
| 80 | + |
| 81 | + render Docs::VisualCodeExample.new(title: "Header and footer", context: self) do |
| 82 | + <<~RUBY |
| 83 | + Message do |
| 84 | + MessageAvatar do |
| 85 | + Avatar(size: :sm) do |
| 86 | + AvatarFallback { "OL" } |
| 87 | + end |
| 88 | + end |
| 89 | + MessageContent do |
| 90 | + MessageHeader { "Oliver" } |
| 91 | + Bubble(variant: :muted) do |
| 92 | + BubbleContent { "Pushed the fix, can you review?" } |
| 93 | + end |
| 94 | + MessageFooter { "9:41 AM" } |
| 95 | + end |
| 96 | + end |
| 97 | + RUBY |
| 98 | + end |
| 99 | + |
| 100 | + Heading(level: 2) { "Alignment" } |
| 101 | + |
| 102 | + render Docs::VisualCodeExample.new(title: "Sender and receiver", context: self) do |
| 103 | + <<~RUBY |
| 104 | + div(class: "flex flex-col gap-6") do |
| 105 | + Message do |
| 106 | + MessageAvatar do |
| 107 | + Avatar(size: :sm) { AvatarFallback { "R" } } |
| 108 | + end |
| 109 | + MessageContent do |
| 110 | + Bubble(variant: :muted) { BubbleContent { "Aligned to the start." } } |
| 111 | + end |
| 112 | + end |
| 113 | + Message(align: :end) do |
| 114 | + MessageAvatar do |
| 115 | + Avatar(size: :sm) { AvatarFallback { "ME" } } |
| 116 | + end |
| 117 | + MessageContent do |
| 118 | + Bubble { BubbleContent { "Aligned to the end." } } |
| 119 | + end |
| 120 | + end |
| 121 | + end |
| 122 | + RUBY |
| 123 | + end |
| 124 | + |
| 125 | + Heading(level: 2) { "Group" } |
| 126 | + |
| 127 | + render Docs::VisualCodeExample.new(title: "Message group", context: self) do |
| 128 | + <<~RUBY |
| 129 | + MessageGroup do |
| 130 | + Message do |
| 131 | + MessageAvatar do |
| 132 | + Avatar(size: :sm) { AvatarFallback { "R" } } |
| 133 | + end |
| 134 | + MessageContent do |
| 135 | + Bubble(variant: :muted) { BubbleContent { "First message." } } |
| 136 | + end |
| 137 | + end |
| 138 | + Message do |
| 139 | + MessageAvatar do |
| 140 | + Avatar(size: :sm) { AvatarFallback { "R" } } |
| 141 | + end |
| 142 | + MessageContent do |
| 143 | + Bubble(variant: :muted) { BubbleContent { "Second, tighter spacing." } } |
| 144 | + end |
| 145 | + end |
| 146 | + end |
| 147 | + RUBY |
| 148 | + end |
| 149 | + |
| 150 | + render Components::ComponentSetup::Tabs.new(component_name: component) |
| 151 | + |
| 152 | + # components |
| 153 | + render Docs::ComponentsTable.new(component_files(component)) |
| 154 | + end |
| 155 | + end |
| 156 | +end |
0 commit comments