source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/popover.rb | Ruby | mit | 91 | master | 4,884 | # frozen_string_literal: true
module Protos
# A popover component that displays content in a floating container
#
# Like a dropdown, but instead of a list of menu items, it's just
# a rendered block. The popover is triggered by a button or link.
#
# Dropdowns, and popovers in general, use tippy.js to posit... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/avatar.rb | Ruby | mit | 91 | master | 2,796 | # frozen_string_literal: true
module Protos
# An avatar component for displaying user or entity images
#
# @see https://daisyui.com/components/avatar/
#
# @example Basic avatar
# render Protos::Avatar.new do
# img(src: "user.jpg", alt: "User avatar")
# end
#
# @example Avatar with indicator... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/tailwind_merge.rb | Ruby | mit | 91 | master | 1,795 | # frozen_string_literal: true
module Protos
class TailwindMerge
DEFAULTS = ::TailwindMerge::Config::DEFAULTS
DAISY_CLASS_GROUPS = {
alert_colors: [
{ alert: Protos::Alert::Colors.values.map(&:to_s) }
],
alert_variants: [
{ alert: Protos::Alert::Variants.values.map(&:to_s) }... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/breadcrumbs.rb | Ruby | mit | 91 | master | 1,388 | # frozen_string_literal: true
module Protos
# A breadcrumbs component for navigation hierarchy
#
# @see https://daisyui.com/components/breadcrumbs/
#
# @example Basic breadcrumbs
# render Protos::Breadcrumbs.new do |breadcrumbs|
# breadcrumbs.crumb { a(href: "/") { "Home" } }
# breadcrumbs.cr... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/types.rb | Ruby | mit | 91 | master | 346 | # frozen_string_literal: true
module Protos
module Types
include Dry.Types()
Colors = Types::Coercible::Symbol.enum(
:default,
:primary,
:secondary,
:accent,
:info,
:success,
:warning,
:error
)
Sizes = Types::Coercible::Symbol.enum(:default, :xs, :sm,... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/token_list.rb | Ruby | mit | 91 | master | 968 | # frozen_string_literal: true
module Protos
# A list of utility tokens that can handle parsing and merging sets of
# tokens together safely.
class TokenList
attr_reader :tokens
autoload :Tokens, "protos/token_list/tokens"
def initialize(tokens = [])
@tokens = Tokens.new(tokens)
end
d... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/swap.rb | Ruby | mit | 91 | master | 1,390 | # frozen_string_literal: true
module Protos
# The swap component is a checkbox that can be toggled on and off to
# display different content.
#
# @see https://daisyui.com/components/swap/
#
# @example
# render Protos::Swap.new do |swap|
# swap.on { "Content when on" }
# swap.off { "Content ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/chat_bubble/footer.rb | Ruby | mit | 91 | master | 497 | # frozen_string_literal: true
module Protos
class ChatBubble
# The footer of a chat bubble
class Footer < Component
# Renders the chat bubble footer element.
#
# @yield The content block for the footer content
# (timestamp, status, etc.).
# @return [nil] outputs to the @buffer... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/chat_bubble/image.rb | Ruby | mit | 91 | master | 526 | # frozen_string_literal: true
module Protos
class ChatBubble
# An image within a chat bubble. This would typically be an avatar
# component.
class Image < Component
# Renders the chat bubble image element.
#
# @yield The content block for the image content (avatar, etc.).
# @retur... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/chat_bubble/header.rb | Ruby | mit | 91 | master | 565 | # frozen_string_literal: true
module Protos
class ChatBubble
# The header of a chat bubble. This is typically used to display the
# name of the user who sent the message.
class Header < Component
# Renders the chat bubble header element.
#
# @yield The content block for the header conte... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/chat_bubble/content.rb | Ruby | mit | 91 | master | 1,227 | # frozen_string_literal: true
module Protos
class ChatBubble
# The main content of a chat bubble. This would normally be the text
# content of the message. It will be colored according to the type.
class Content < Component
STYLES = {
default: "",
accent: "chat-bubble-accent",
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/diff/item.rb | Ruby | mit | 91 | master | 746 | # frozen_string_literal: true
module Protos
class Diff
class Item < Component
Order = Types::Coercible::Symbol.enum(:one, :two)
ORDER = {
one: "diff-item-1",
two: "diff-item-2"
}.freeze
# @!attribute [r] order
# @return [Order]
option :order, type: Order, def... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/diff/resizer.rb | Ruby | mit | 91 | master | 513 | # frozen_string_literal: true
module Protos
class Diff
# The resizer element that allows dragging to adjust the split between
# diff items
class Resizer < Component
# Renders the resizer element.
#
# @yield The content block for the resizer (usually empty).
# @return [nil] outputs... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/breadcrumbs/crumb.rb | Ruby | mit | 91 | master | 373 | # frozen_string_literal: true
module Protos
class Breadcrumbs
# A single breadcrumb item
class Crumb < Component
# Renders the breadcrumb item element.
#
# @yield The content block for the crumb content (usually a link).
# @return [nil] outputs to the @buffer
def view_template(&... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/table/cell.rb | Ruby | mit | 91 | master | 744 | # frozen_string_literal: true
module Protos
class Table
# A single cell in a table
class Cell < Component
ALLIGNMENT = {
left: "text-left",
right: "text-right",
center: "text-center"
}.freeze
option :align,
type: Types::Coercible::Symbol.enum(:left, :center,... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/table/row.rb | Ruby | mit | 91 | master | 490 | # frozen_string_literal: true
module Protos
class Table
# A table row (tr element) that contains cells of data.
#
# @example Basic usage
# table.row do
# table.cell { "Data 1" }
# table.cell { "Data 2" }
# end
class Row < Component
def view_template(&)
tr(**a... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/table/footer.rb | Ruby | mit | 91 | master | 543 | # frozen_string_literal: true
module Protos
class Table
# The footer section of a table (tfoot element) that typically
# contains summary rows.
#
# @example Basic usage
# table.footer do
# table.row do
# table.cell { "Total" }
# table.cell { "100" }
# end
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/table/caption.rb | Ruby | mit | 91 | master | 569 | # frozen_string_literal: true
module Protos
class Table
# The caption of a table
class Caption < Component
Sides = Types::Coercible::Symbol.enum(:bottom, :top)
SIDES = {
bottom: "caption-bottom",
top: "caption-top"
}.freeze
option :side,
type: Sides,
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/table/head.rb | Ruby | mit | 91 | master | 865 | # frozen_string_literal: true
module Protos
class Table
# A table header cell (th element) that represents a column header.
# Can be aligned left, center or right.
#
# @example With alignment
# table.head(align: :center) { "Centered Header" }
class Head < Component
ALLIGNMENT = {
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/table/header.rb | Ruby | mit | 91 | master | 598 | # frozen_string_literal: true
module Protos
class Table
# The header section of a table that contains column headers.
# This wraps one or more Protos::Table::Head components in a thead
# element.
#
# @example Basic usage
# table.header do
# table.row do
# table.head { "Nam... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/table/body.rb | Ruby | mit | 91 | master | 427 | # frozen_string_literal: true
module Protos
class Table
# The main content area of a table (tbody element) that contains
# the data rows.
#
# @example Basic usage
# table.body do
# table.row do
# table.cell { "John" }
# table.cell { "30" }
# end
# end
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/dropdown/menu.rb | Ruby | mit | 91 | master | 871 | # frozen_string_literal: true
module Protos
class Dropdown
# The container for items in a dropdown. This is a restyled
# Protos::Popover::Content component as the main functionality for
# dropdowns comes from there.
class Menu < Popover::Content
option :as_template, default: -> { true }
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/dropdown/trigger.rb | Ruby | mit | 91 | master | 245 | # frozen_string_literal: true
module Protos
class Dropdown
# The trigger for a dropdown. This inherits from the trigger of
# a popover as the main functionality comes from there.
class Trigger < Popover::Trigger
end
end
end |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/dropdown/item.rb | Ruby | mit | 91 | master | 348 | # frozen_string_literal: true
module Protos
class Dropdown
# A single item within a dropdown
class Item < Component
# Renders the dropdown item element.
#
# @yield The content block for the item.
# @return [nil] outputs to the @buffer
def view_template(&)
li(**attrs, &)
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/typography/inline_link.rb | Ruby | mit | 91 | master | 437 | # frozen_string_literal: true
module Protos
module Typography
# A link that is styled to be inline with text
class InlineLink < Component
def view_template(&)
a(**attrs, &)
end
private
def theme
{
container: %w[
font-semibold
hover:u... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/typography/paragraph.rb | Ruby | mit | 91 | master | 426 | # frozen_string_literal: true
module Protos
module Typography
# A paragraph of text
class Paragraph < Component
option :margin, default: -> { true }
def view_template(&)
p(**attrs, &)
end
private
def theme
{
container: [
"leading-relaxed"... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/typography/heading.rb | Ruby | mit | 91 | master | 1,017 | # frozen_string_literal: true
module Protos
module Typography
# A heading component that encapsulates all heading levels by their
# size and level.
class Heading < Protos::Component
Sizes = Types::Coercible::Symbol.enum(:xs, :sm, :md, :lg, :xl)
Levels = Types::Integer.enum(1, 2, 3, 4, 5, 6)
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/toast/close_button.rb | Ruby | mit | 91 | master | 1,184 | # frozen_string_literal: true
module Protos
class Toast
# A button that closes the toast when clicked.
#
# @example Basic close button
# toast.close_button { "×" }
#
# @example Close button with icon
# toast.close_button { icon(:x_mark) }
#
# @note This component:
# - Wr... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/card/body.rb | Ruby | mit | 91 | master | 453 | # frozen_string_literal: true
module Protos
class Card
# The main content area of a card
class Body < Component
# Renders the card body container.
#
# @yield The content block for the card's main content.
# @return [nil] outputs to the @buffer
def view_template(&)
div(**... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/card/image.rb | Ruby | mit | 91 | master | 503 | # frozen_string_literal: true
module Protos
class Card
# A container for an image on a card. This matches the examples
# on daisyui which will style the <figure> tag depending on whether
# image-overlay is present on the card.
class Image < Component
# Renders the card image container.
#
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/card/title.rb | Ruby | mit | 91 | master | 433 | # frozen_string_literal: true
module Protos
class Card
# The title of a card
class Title < Component
# Renders the card title element.
#
# @yield The content block for the title text.
# @return [nil] outputs to the @buffer
def view_template(&)
div(**attrs, &)
end
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/card/actions.rb | Ruby | mit | 91 | master | 478 | # frozen_string_literal: true
module Protos
class Card
# Area for actions (e.g buttons) within a card
class Actions < Component
# Renders the card actions container.
#
# @yield The content block for action buttons or controls.
# @return [nil] outputs to the @buffer
def view_temp... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/tabs/tab.rb | Ruby | mit | 91 | master | 562 | # frozen_string_literal: true
module Protos
class Tabs
# A single tab in a tabs component
class Tab < Component
option :active, default: -> { false }
option :disabled, default: -> { false }
def view_template(&)
a(**attrs, &)
end
private
def default_attrs
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/popover/trigger.rb | Ruby | mit | 91 | master | 960 | # frozen_string_literal: true
module Protos
class Popover
# The interactive element that activates the popover when hovered or
# clicked.
#
# @example Basic trigger
# popover.trigger { "Hover me" }
#
# @example Custom styled trigger
# popover.trigger(class: "btn btn-primary") { "C... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/popover/content.rb | Ruby | mit | 91 | master | 1,146 | # frozen_string_literal: true
module Protos
class Popover
# The content that appears in the popover when triggered.
#
# @example Basic content
# popover.content { "Popover message" }
#
# @example Rich content
# popover.content do
# div(class: "p-4") do
# h3 { "Title"... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/floating_action_button/open_button.rb | Ruby | mit | 91 | master | 380 | # frozen_string_literal: true
module Protos
class FloatingActionButton
class OpenButton < Component
def view_template(&)
div(**attrs, &)
end
private
def default_attrs
{
role: "button",
tabindex: "0"
}
end
def theme
{
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/floating_action_button/close_button.rb | Ruby | mit | 91 | master | 282 | # frozen_string_literal: true
module Protos
class FloatingActionButton
class CloseButton < Component
def view_template(&)
div(**attrs, &)
end
private
def theme
{
container: "fab-close"
}
end
end
end
end |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/modal/dialog.rb | Ruby | mit | 91 | master | 1,271 | # frozen_string_literal: true
module Protos
class Modal
# The container for modal content that appears when triggered.
#
# @example Basic dialog
# modal.dialog do
# h2 { "Title" }
# p { "Content goes here" }
# modal.close_button { "Close" }
# end
#
# @example D... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/modal/trigger.rb | Ruby | mit | 91 | master | 654 | # frozen_string_literal: true
module Protos
class Modal
# A button that opens the modal when clicked.
#
# @example Basic trigger
# modal.trigger { "Open Modal" }
#
# @example Trigger with custom styling
# modal.trigger(class: "btn btn-primary") { "Click Me" }
#
# @note This co... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/modal/close_button.rb | Ruby | mit | 91 | master | 813 | # frozen_string_literal: true
module Protos
class Modal
# A button that closes the modal when clicked.
#
# @example Basic close button
# modal.close_button { "Close" }
#
# @example Close button with icon
# modal.close_button { icon(:x_mark) }
#
# @note This component:
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/menu/item.rb | Ruby | mit | 91 | master | 923 | # frozen_string_literal: true
module Protos
class Menu
# A single item in a menu, typically containing a link or action.
#
# @see https://daisyui.com/components/menu/
#
# @example Basic menu item
# menu.item { a(href: "/home") { "Home" } }
#
# @example Menu title item
# menu.i... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/token_list/tokens.rb | Ruby | mit | 91 | master | 988 | # frozen_string_literal: true
module Protos
class TokenList
# This is used in place of a `Set` as a performance optimization.
# Testing the memory and profiling the performance says that this is much
# better
class Tokens
# @param tokens [Array<String>]
def initialize(tokens)
@tok... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/steps/step.rb | Ruby | mit | 91 | master | 1,500 | # frozen_string_literal: true
module Protos
class Steps
# A single step in a steps component.
#
# @example Basic step
# steps.step { "Step 1" }
#
# @example Colored step
# steps.step(type: :primary) { "Completed Step" }
#
# @example With custom content
# steps.step do
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/collapse/content.rb | Ruby | mit | 91 | master | 526 | # frozen_string_literal: true
module Protos
class Collapse
# The content of a collapse. This would be hidden until the collapse
# is opened.
class Content < Component
# Renders the collapse content container.
#
# @yield The content block for the collapsible content.
# @return [nil... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/collapse/title.rb | Ruby | mit | 91 | master | 882 | # frozen_string_literal: true
module Protos
class Collapse
# The title of a collapse. This is the content that is always
# visible and is used to toggle the collapse.
class Title < Component
# @!attribute [r] input_id
# @return [String, Integer, nil] The ID of the associated input
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/timeline/right.rb | Ruby | mit | 91 | master | 850 | # frozen_string_literal: true
module Protos
class Timeline
# Content on the right side of a timeline item (typically event details).
#
# @example Basic usage
# timeline.right { "Product Launch" }
#
# @example With rich content
# timeline.right do
# h3 { "Version 2.0" }
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/timeline/item.rb | Ruby | mit | 91 | master | 954 | # frozen_string_literal: true
module Protos
class Timeline
# A single item in a timeline, containing left, center and right sections.
#
# @example Basic item
# timeline.item do
# timeline.left { "2023" }
# timeline.center { "●" }
# timeline.right { "First Release" }
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/timeline/left.rb | Ruby | mit | 91 | master | 794 | # frozen_string_literal: true
module Protos
class Timeline
# Content on the left side of a timeline item (typically dates/times).
#
# @example Basic usage
# timeline.left { "Jan 2023" }
#
# @example With custom styling
# timeline.left(class: "font-bold") { "Q1 2024" }
#
# @not... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/timeline/center.rb | Ruby | mit | 91 | master | 801 | # frozen_string_literal: true
module Protos
class Timeline
# The visual marker/indicator at the center of a timeline item.
#
# @example With dot marker
# timeline.center { "●" }
#
# @example With icon
# timeline.center { icon(:check) }
#
# @example Custom styled
# timeli... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/alert/icon.rb | Ruby | mit | 91 | master | 363 | # frozen_string_literal: true
module Protos
class Alert
# Icon for the alert, usually showing at the top left corner aligned
# to the text
class Icon < Component
def view_template(&)
div(**attrs, &)
end
private
def theme
{
container: "place-self-start m... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/alert/actions.rb | Ruby | mit | 91 | master | 424 | # frozen_string_literal: true
module Protos
class Alert
# Area for actions (e.g buttons) within an alert
class Actions < Component
def view_template(&)
nav(**attrs, &)
end
private
def default_attrs
{
aria_label: "alert-actions"
}
end
de... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/hero/overlay.rb | Ruby | mit | 91 | master | 616 | # frozen_string_literal: true
module Protos
class Hero
# The overlay of a hero. This would be used with images to reduce
# their opacity through the opacity of the overlay. This can be useful to
# make text readable on noisy images.
class Overlay < Component
# Renders the hero overlay element.
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/hero/content.rb | Ruby | mit | 91 | master | 512 | # frozen_string_literal: true
module Protos
class Hero
# The content of a hero. This would be centered within the main
# component container.
class Content < Component
# Renders the hero content container.
#
# @yield The content block for the hero content.
# @return [nil] outputs ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/command/title.rb | Ruby | mit | 91 | master | 535 | # frozen_string_literal: true
module Protos
class Command
# The title for a group of commands. This is expected to be used
# inside a Protos::Command::Group component.
class Title < Component
# Renders the command group title.
#
# @yield The content block for the title text.
# @re... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/command/trigger.rb | Ruby | mit | 91 | master | 509 | # frozen_string_literal: true
module Protos
class Command
# A trigger is a button that opens a command palette modal
class Trigger < Component
# Renders the command trigger button.
#
# @yield The content block for the button content.
# @return [nil] outputs to the @buffer
def vi... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/command/list.rb | Ruby | mit | 91 | master | 594 | # frozen_string_literal: true
module Protos
class Command
# A list of commands. This can contain either items or groups.
class List < Component
# Renders the command list container.
#
# @yield The content block to define command items and groups.
# @return [nil] outputs to the @buffer... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/command/group.rb | Ruby | mit | 91 | master | 687 | # frozen_string_literal: true
module Protos
class Command
# An optional group for holding a heading and a list of options.
# Items in the group will have a divider line on the left side and can
# optionally have a title.
class Group < Component
# Renders the command group container.
#
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/command/input.rb | Ruby | mit | 91 | master | 1,300 | # frozen_string_literal: true
module Protos
class Command
# The search input for the command palette
class Input < Component
# @!attribute [r] placeholder
# @return [String] Placeholder text for the input field.
option :placeholder,
default: -> {
"Type a command or search.... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/command/item.rb | Ruby | mit | 91 | master | 572 | # frozen_string_literal: true
module Protos
class Command
# A single option within a command
class Item < Component
# Renders the command item element.
#
# @yield The content block for the item content.
# @return [nil] outputs to the @buffer
def view_template(&)
li(**att... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/command/empty.rb | Ruby | mit | 91 | master | 632 | # frozen_string_literal: true
module Protos
class Command
# The empty component is displayed in the list when there are no
# matches in an input.
class Empty < Component
# Renders the empty state element.
#
# @yield The content block for the empty state message.
# @return [nil] ou... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/stats/title.rb | Ruby | mit | 91 | master | 640 | # frozen_string_literal: true
module Protos
class Stats
# The title/label for a statistic.
#
# @example Basic title
# stats.title { "Total Revenue" }
#
# @example With custom styling
# stats.title(class: "text-sm") { "Monthly Active Users" }
#
# @note This component:
# -... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/stats/description.rb | Ruby | mit | 91 | master | 784 | # frozen_string_literal: true
module Protos
class Stats
# Supplemental text providing context for the statistic.
#
# @example Basic description
# stats.description { "10% increase from last month" }
#
# @example With trend indicator
# stats.description do
# span(class: "text-s... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/stats/value.rb | Ruby | mit | 91 | master | 629 | # frozen_string_literal: true
module Protos
class Stats
# The numeric value of the statistic.
#
# @example Basic value
# stats.value { "1,234" }
#
# @example With currency
# stats.value { "$1,234.56" }
#
# @note This component:
# - Typically appears below the title
#... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/stats/figure.rb | Ruby | mit | 91 | master | 667 | # frozen_string_literal: true
module Protos
class Stats
# An optional decorative element for a stat, typically an icon or image.
#
# @example With icon
# stats.figure { icon(:users) }
#
# @example With image
# stats.figure { img(src: "chart.png") }
#
# @note This component:
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/stats/actions.rb | Ruby | mit | 91 | master | 771 | # frozen_string_literal: true
module Protos
class Stats
# A container for interactive elements related to the statistic.
#
# @example With single button
# stats.actions { button { "View Details" } }
#
# @example With multiple actions
# stats.actions do
# button { "Export" }
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/stats/stat.rb | Ruby | mit | 91 | master | 1,047 | # frozen_string_literal: true
module Protos
class Stats
class Stat < Component
# A container for a single statistic with title, value and optional
# elements.
#
# @example Basic stat
# stats.stat do
# stats.title { "Users" }
# stats.value { "1,234" }
# ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/list/item.rb | Ruby | mit | 91 | master | 685 | # frozen_string_literal: true
module Protos
class List
# A single item within a list. Items are joined so that borders will
# work for list items, including border radius. E.g. only the first and
# last items will have border radius on the top and bottom.
class Item < Component
option :wrap, Ty... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/accordion/item.rb | Ruby | mit | 91 | master | 1,176 | # frozen_string_literal: true
module Protos
class Accordion
# An accordion item containing a title and collapsible content
class Item < Component
# @!attribute [r] input_name
# @return [String, Integer, nil] Name/ID for the radio input.
option :input_name,
type: Types::String | Ty... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/drawer/content.rb | Ruby | mit | 91 | master | 541 | # frozen_string_literal: true
module Protos
class Drawer
# The content of a drawer. This would be visible at all times and
# represents the main content of your page.
class Content < Component
# Renders the drawer content container.
#
# @yield The content block for the main content.
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/drawer/side.rb | Ruby | mit | 91 | master | 993 | # frozen_string_literal: true
module Protos
class Drawer
# The content that will be shown when you open the drawer using the
# trigger. This would be hidden until triggered.
class Side < Component
# @!attribute [r] input_id
# @return [String] The ID of the associated checkbox input for togg... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/drawer/trigger.rb | Ruby | mit | 91 | master | 751 | # frozen_string_literal: true
module Protos
class Drawer
# The trigger for a drawer. When this is clicked the side will open
# and overlap the main content with a darker overlay.
class Trigger < Component
# @!attribute [r] input_id
# @return [String] The ID of the associated checkbox input ... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/carousel/item.rb | Ruby | mit | 91 | master | 456 | # frozen_string_literal: true
module Protos
class Carousel
# A single item within a carousel
class Item < Component
# Renders the carousel item element.
#
# @yield The content block for the item content.
# @return [nil] outputs to the @buffer
def view_template(&)
div(**a... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/carousel/actions.rb | Ruby | mit | 91 | master | 669 | # frozen_string_literal: true
module Protos
class Carousel
# Area for actions (e.g buttons) within a carousel
class Actions < Component
# Renders the carousel actions container.
#
# @yield The content block for action buttons or controls.
# @return [nil] outputs to the @buffer
d... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/swap/on.rb | Ruby | mit | 91 | master | 735 | # frozen_string_literal: true
module Protos
class Swap
# The content that displays when the swap is in the "on" state.
#
# @example Basic usage
# swap.on { "Active State" }
#
# @example With custom styling
# swap.on(class: "text-success") { icon(:check) }
#
# @note This compon... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | lib/protos/swap/off.rb | Ruby | mit | 91 | master | 744 | # frozen_string_literal: true
module Protos
class Swap
# The content that displays when the swap is in the "off" state.
#
# @example Basic usage
# swap.off { "Inactive State" }
#
# @example With custom styling
# swap.off(class: "text-error") { icon(:x_mark) }
#
# @note This co... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | rakelib/memory.rake | Ruby | mit | 91 | master | 793 | # frozen_string_literal: true
require "memory_profiler"
require "protos"
require_relative "support/protos_table"
# require_relative "support/phlex_table"
# Force autoloading of tailwind merger
_ = Protos::Theme.merger
namespace :memory do
desc "Memory report for Protos::Table"
task :table do
report = Memory... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | rakelib/profile.rake | Ruby | mit | 91 | master | 1,850 | # frozen_string_literal: true
require "protos"
require "ruby-prof"
require "ruby-prof-speedscope"
require_relative "support/protos_table"
require_relative "support/phlex_table"
TMP_DIR = File.expand_path("../tmp", __dir__)
FileUtils.mkdir_p(TMP_DIR)
def output_result(result, name)
flat_path = File.join(TMP_... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | rakelib/benchmark.rake | Ruby | mit | 91 | master | 3,693 | # frozen_string_literal: true
require "benchmark"
require "benchmark/ips"
require "benchmark/memory"
require "protos"
require_relative "support/protos_table"
require_relative "support/phlex_table"
namespace :benchmark do
namespace :ips do
desc "Run Protos::Mix ips benchmarks"
task :mix do
Benchmark.i... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | rakelib/support/phlex_table.rb | Ruby | mit | 91 | master | 492 | # frozen_string_literal: true
class PhlexTable < Phlex::HTML
def view_template # rubocop:disable Metrics/MethodLength
table do
thead do
tr do
th { "Name" }
th { "Age" }
end
end
tbody do
100.times do |i|
tr do
td { "John Doe" }
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | rakelib/support/protos_table.rb | Ruby | mit | 91 | master | 614 | # frozen_string_literal: true
class ProtosTable < Protos::Component
def view_template # rubocop:disable Metrics/MethodLength
render Protos::Table.new do |table|
table.header do
table.row do
table.head { "Name" }
table.head { "Age" }
end
end
table.body do
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/spec_helper.rb | Ruby | mit | 91 | master | 458 | # frozen_string_literal: true
require "debug"
require "protos"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
c... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/support/matchers.rb | Ruby | mit | 91 | master | 600 | # frozen_string_literal: true
class HaveStimulusTarget
def initialize(controller, target)
@controller = controller
@target = target
end
def matches?(page)
@page = page
@page.has_css?("[data-#{@controller}-target='#{@target}']")
end
def failure_message
"expected page to have a stimulus t... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/support/phlex.rb | Ruby | mit | 91 | master | 328 | # frozen_string_literal: true
module ComponentHelpers
def render(component, ...)
result = component.call(...)
@raw_page = result
@page = Capybara::Node::Simple.new(result)
end
def raw_page
@raw_page
end
def page
@page
end
end
RSpec.configure do |config|
config.include ComponentHelp... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/token_list_spec.rb | Ruby | mit | 91 | master | 1,145 | # frozen_string_literal: true
RSpec.describe Protos::TokenList do
describe "#clear" do
it "clears the list" do
subject.add("foo")
subject.clear
expect(subject.to_s).to eq("")
end
end
describe "#add" do
it "adds the given token to the list" do
subject.add("baz")
expect... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/diff_spec.rb | Ruby | mit | 91 | master | 534 | # frozen_string_literal: true
RSpec.describe Protos::Diff do
subject { page }
before do
render described_class.new do |diff|
diff.item_one { "Item 1" }
diff.item_two { "Item 2" }
diff.resizer
end
end
context "content" do
it { is_expected.to have_content("Item 1") }
it { is_e... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/tabs_spec.rb | Ruby | mit | 91 | master | 530 | # frozen_string_literal: true
RSpec.describe Protos::Tabs do
subject { page }
before do
render described_class.new(type: :lifted, size: :lg) do |tabs|
tabs.tab { "Tab 1" }
tabs.tab { "Tab 2" }
end
end
context "content" do
it { is_expected.to have_content("Tab 1") }
it { is_expecte... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/dropdown_spec.rb | Ruby | mit | 91 | master | 888 | # frozen_string_literal: true
RSpec.describe Protos::Dropdown do
subject do
described_class.new(options: { boundary: "viewport" }) do |dropdown|
dropdown.trigger { "Trigger" }
dropdown.menu(class: "custom-menu-class") do
dropdown.item { "Item 1" }
dropdown.item { "Item 2" }
end
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/chat_bubble_spec.rb | Ruby | mit | 91 | master | 738 | # frozen_string_literal: true
RSpec.describe Protos::ChatBubble do
subject do
described_class.new(align: :end) do |chat|
chat.header { "Chat bubble header" }
chat.image { chat.img(src: "#") }
chat.content { "Chat bubble content" }
chat.footer { "Chat bubble footer" }
end
end
befo... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/table_spec.rb | Ruby | mit | 91 | master | 1,626 | # frozen_string_literal: true
RSpec.describe Protos::Table do
subject do
described_class.new(
pin_rows: true,
pin_columns: true,
striped: true,
size: :lg
) do |table|
table.caption { "Table caption" }
table.header do
table.row do
table.head { "Name" }
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/timeline_spec.rb | Ruby | mit | 91 | master | 748 | # frozen_string_literal: true
RSpec.describe Protos::Timeline do
subject do
described_class.new(vertical: true) do |timeline|
timeline.item do
timeline.hr
timeline.left { "Left content" }
timeline.center { "Center content" }
timeline.right { "Right content" }
end
e... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/collapse_spec.rb | Ruby | mit | 91 | master | 816 | # frozen_string_literal: true
RSpec.describe Protos::Collapse do
subject { page }
before do
render described_class.new(
checkbox: true,
input_name: "123",
icon: :arrow,
state: :open
) do |collapse|
collapse.title { "Title" }
collapse.content { "Content" }
end
end
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/modal_spec.rb | Ruby | mit | 91 | master | 702 | # frozen_string_literal: true
RSpec.describe Protos::Modal do
subject do
described_class.new do |modal|
modal.trigger { "Trigger" }
modal.dialog do
modal.plain "Content"
modal.close_button { "Close" }
end
end
end
before do
render subject
end
it "renders the mod... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/theme_spec.rb | Ruby | mit | 91 | master | 3,968 | # frozen_string_literal: true
RSpec.describe Protos::Theme do
describe "initialization" do
it "initializes with a hash or keywords" do
expect { described_class.new({ foo: "bar" }) }
.not_to raise_error
expect { described_class.new(foo: "bar") }
.not_to raise_error
end
end
des... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/card_spec.rb | Ruby | mit | 91 | master | 878 | # frozen_string_literal: true
RSpec.describe Protos::Card do
subject do
described_class.new(
border: true,
image_full: true
) do |card|
card.image { card.img(src: "#") }
card.body do
card.title { "Hello world" }
card.plain "This is a card"
card.actions do
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/accordion_spec.rb | Ruby | mit | 91 | master | 1,257 | # frozen_string_literal: true
RSpec.describe Protos::Accordion do
subject { page }
context "as a radio button group" do
before do
render described_class.new(input_name: "123") do |accordion|
accordion.item do
accordion.title { "Item 1" }
accordion.content { "Content 1" }
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/toast_spec.rb | Ruby | mit | 91 | master | 585 | # frozen_string_literal: true
RSpec.describe Protos::Toast do
subject do
described_class.new(position: :top_center) do |toast|
toast.plain "Toast content"
toast.close_button { "Close" }
end
end
before { render subject }
it "renders a toast" do
expect(page).to have_css("dialog[open]")
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/badge_spec.rb | Ruby | mit | 91 | master | 1,199 | # frozen_string_literal: true
RSpec.describe Protos::Badge do
subject { page }
before do
render described_class.new do
"Some content"
end
end
it { is_expected.to have_css(".badge") }
it { is_expected.to have_no_css(".badge-outline") }
it { is_expected.to have_css("span") }
it { is_expecte... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/mix_spec.rb | Ruby | mit | 91 | master | 1,234 | # frozen_string_literal: true
RSpec.describe Protos::Mix do
describe "#call" do
it "handles a nil value" do
attrs = { foo: "bar" }
result = subject.call(attrs, nil)
expect(result[:foo]).to eq("bar")
end
it "merges the mergeable attributes" do
result = subject.call(
{
... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/attributes_spec.rb | Ruby | mit | 91 | master | 583 | # frozen_string_literal: true
RSpec.describe Protos::Attributes do
describe "#initialize" do
it "accepts a hash of attributes or keywords" do
expect { described_class.new({ foo: "bar" }) }
.not_to raise_error
expect { described_class.new(foo: "bar") }
.not_to raise_error
end
end... |
github | inhouse-work/protos | https://github.com/inhouse-work/protos | spec/protos/typography_spec.rb | Ruby | mit | 91 | master | 625 | # frozen_string_literal: true
RSpec.describe Protos::Typography do
before do
stub_const(
"TypographyTestComponent", Class.new(Protos::Component) do
include Protos::Typography
def view_template(&block)
h1(**attrs, &block)
end
end
)
render TypographyTestCompo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.