element-plus/docs/en-US/component/rate.md
MoConWu 5ee184fdfd
feat(theme-chalk): css var for empty & rate (#5359)
* 更新var.scss,提取empty的fill-color

将fill的color提取出来,作为变量,方便后续修改,修改如下:
    'fill-color-0': var(--el-color-white),
    'fill-color-1': #FCFCFD,
    'fill-color-2': #F8F9FB,
    'fill-color-3': #F7F8FC,
    'fill-color-4': #EEEFF3,
    'fill-color-5': #EDEEF2,
    'fill-color-6': #E9EBEF,
    'fill-color-7': #E5E7E9,
    'fill-color-8': #E0E3E9,
    'fill-color-9': #D5D7DE,

* 修改Empty的fillcolor作为变量引用,方便后续的色彩搭配更改

修改Empty的fillcolor作为变量引用,方便后续的色彩搭配更改

* 修改rate下的配色提取到变量里

修改rate下的配色提取到变量里,提取如下:
    'void-color': #c6d1de,
    'rate-color': #F7BA2A,

* 提取rate的色彩作为变量

提取rate的色彩作为变量

* 修改rate的色彩变量

修改和提取rate变量为:
    'void-color': #c6d1de,
    'star-color': #F7BA2A,
    'disable-void-color': #EFF2F7,
    'text-color': #1f2d3d,

* replace space to enter

替換空格为回车

* lint change

lint change

* Missing Pretty error

color 颜色小写

* Add CustomStyles infomation

Add CustomStyles infomation

* Change CustomStyles

Change CustomStyles

* Add CustomStyles

Add CustomStyles

* Change rate to empty

Change rate to empty

* Modify CustomStyles after Bottom content

Modify CustomStyles after Bottom content

* Change Custom styles

Change Custom styles

* feat: format rate.md
2022-01-26 02:10:19 +08:00

10 KiB

title lang
Rate en-US

Rate

Used for rating

Basic usage

:::demo Rate divides rating scores into several levels and these levels can be distinguished by using different background colors. By default background colors are the same, but you can assign them an array with three element to reflect three levels using the colors attribute, and their two thresholds can be defined by low-threshold and high-threshold, or you can assign them with a object which key is the threshold between two levels and value is the corresponding color.

rate/basic-usage

:::

Sizes

:::demo

rate/sizes

:::

With allow-half

:::demo Add attribute allow-half Half star allowed

rate/allow-half

:::

With text

Using text to indicate rating score

:::demo Add attribute show-text to display text at the right of Rate. You can assign texts for different scores using texts. texts is an array whose length should be equal to the max score max.

rate/text

:::

More icons

You can use different icons to distinguish different rate components.

:::demo You can customize icons by passing icons an array with three elements or a object which key is the threshold between two levels and value is the corresponding icon. In this example, we also use void-icon to set the icon if it is unselected.

rate/more-icons

:::

Read-only

Read-only Rate is for displaying rating score. Half star is supported.

:::demo Use attribute disabled to make the component read-only. Add show-score to display the rating score at the right side. Additionally, you can use attribute score-template to provide a score template. It must contain {value}, and {value} will be replaced with the rating score.

rate/readonly

:::

Custom styles

Now you can set custom style for rate component. Use css/scss language to change the global or local color. We set some global color variables: --el-rate-void-color, --el-rate-star-color, --el-rate-disable-void-color, --el-rate-text-color. You can use like: :root { --el-rate-void-color: red; --el-rate-star-color: blue; }.

Default Variables

Variable Color
--el-rate-void-color #c6d1de
--el-rate-star-color #f7ba2a
--el-rate-disable-void-color #eff2f7
--el-rate-text-color #1f2d3d

:::

Attributes

Attribute Description Type Accepted Values Default
model-value / v-model binding value number 0
max max rating score number 5
size size of Rate string large / default / small default
disabled whether Rate is read-only boolean false
allow-half whether picking half start is allowed boolean false
low-threshold threshold value between low and medium level. The value itself will be included in low level number 2
high-threshold threshold value between medium and high level. The value itself will be included in high level number 4
colors colors for icons. If array, it should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding color array/object ['#F7BA2A', '#F7BA2A', '#F7BA2A']
void-color color of unselected icons string #C6D1DE
disabled-void-color color of unselected read-only icons string #EFF2F7
icons icon components. If array, ot should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding icon component array/object [StarFilled, StarFilled, StarFilled]
void-icon component of unselected icons string/component Star
disabled-void-icon component of unselected read-only icons string/component StarFilled
show-text whether to display texts boolean false
show-score whether to display current score. show-score and show-text cannot be true at the same time boolean false
text-color color of texts string #1F2D3D
texts text array array ['Extremely bad', 'Disappointed', 'Fair', 'Satisfied', 'Surprise']
score-template score template string {value}

Events

Event Name Description Parameters
change Triggers when rate value is changed value after changing