Sha256: 1f62952fb8aeced450e4d36ec2a7bca7fa3b4e7a6392ce6adeba71ced1d7f8e5
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true module Playbook module PbStarRating class StarRating < Playbook::KitBase prop :rating, type: Playbook::Props::Numeric, default: 0 prop :denominator, type: Playbook::Props::Numeric, default: 5 prop :layout_option, type: Playbook::Props::Enum, values: %w[default onestar number], default: "default" prop :color_option, type: Playbook::Props::Enum, values: %w[yellow primary subtle outline], default: "yellow" prop :size, type: Playbook::Props::Enum, values: %w[xs sm md lg], default: "sm" def star_count rating.floor > denominator_style ? denominator_style : rating.floor end def denominator_style layout_option == "onestar" ? 1 : denominator end def empty_stars (denominator_style - rating.floor).negative? ? 0 : denominator_style - rating.floor end def empty_star_color dark ? "empty_star_dark" : "empty_star_light" end def outline_star_color dark ? "outline_star_dark" : "outline_star_light" end def subtle_star_color dark ? "suble_star_dark" : "suble_star_light" end def svg_size case size when "sx" 14 when "sm" 16 when "md" 24 when "lg" 48 else 16 end end def classname generate_classname("pb_star_rating_kit") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems