Sha256: 73f0a2371c0d0a2618d0ab713988141b45b554eef94b8084d8464cfcf7527929
Contents?: true
Size: 1.63 KB
Versions: 8
Compression:
Stored size: 1.63 KB
Contents
# typed: false # frozen_string_literal: true module Ariadne module UI module Avatar class Component < Ariadne::BaseComponent option :title, default: proc { "" } option :src, optional: true option :size, default: proc { :base } option :circle, default: proc { false } attr_reader :placeholder_text style do base do "select-none object-cover" end variants do size do xs { ["ariadne-size-4", "ariadne-text-xs", "ariadne-rounded"] } sm { ["ariadne-size-5", "ariadne-text-sm", "ariadne-rounded-sm"] } md { ["ariadne-size-8", "ariadne-text-md", "ariadne-rounded-md"] } lg { ["ariadne-size-10", "ariadne-text-lg", "ariadne-rounded-lg"] } xl { ["ariadne-size-12", "ariadne-text-xl", "ariadne-rounded-xl"] } end circle do yes { "!ariadne-rounded-full" } end has_src do no do [ "ariadne-inline-flex", "ariadne-items-center", "ariadne-justify-center", "ariadne-bg-violet-200", "dark:ariadne-bg-violet-800", "ariadne-text-violet-600", "dark:ariadne-text-violet-400", ] end end end end def before_render len = [:xs, :sm, :md].include?(size) ? 0 : 1 @placeholder_text = (title || "").strip.split[0..len].map { |word| word.capitalize[0] }.join end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems