Sha256: d824055e8300437c15905b7a2ccd5a75f494a469e5b5e50e40a8cab3539aedb9
Contents?: true
Size: 1.53 KB
Versions: 12
Compression:
Stored size: 1.53 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-rounded"] } sm { ["ariadne-size-5", "ariadne-rounded-md"] } md { ["ariadne-size-8", "ariadne-rounded-lg"] } lg { ["ariadne-size-10", "ariadne-rounded-xl"] } xl { ["ariadne-size-12", "ariadne-rounded-2xl"] } 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
12 entries across 12 versions & 1 rubygems