Skip to content

Commit

Permalink
feat: add rate
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Aug 3, 2019
1 parent 0badbaf commit e036f13
Show file tree
Hide file tree
Showing 11 changed files with 389 additions and 2 deletions.
5 changes: 5 additions & 0 deletions demo/app/assets/views/documentation.xml
Expand Up @@ -80,6 +80,11 @@
List group
</a>
</w>
<w class="nav-item">
<a class="nav-link" href="components/rate.xml" target="demo-content">
Rate
</a>
</w>
<w class="nav-item">
<a class="nav-link" href="components/modal.xml" target="demo-content">
Modal
Expand Down
47 changes: 47 additions & 0 deletions docs/components/rate.md
@@ -0,0 +1,47 @@
# Rate

Rate component can be used to show evaluation, and it provide a quick rating operation on something.

## Basic

The simplest usage.

``` rate-basic-demo-xml
<rate />
```

## Readonly

Set the `disabled` attribute to disable mouse interaction.

``` rate-readonly-demo-xml
<rate value="2" disabled="disabled" />
```

## Other star count

The default number of stars is 5, you can set it with the `count` attribute.

``` rate-count-demo-xml
<rate count="10" />
```

## Other icon

Replace the default star to other iconfont.

``` rate-icon-demo-xml
<rate icon="heart" void-icon="heart-outline" />
<w class="mb-2" />
<rate icon="emoticon-happy" void-icon="emoticon-neutral-outline" />
```

## Other character

Replace the default star to other character like alphabet, digit or even Chinese word.

``` rate-character-demo-xml
<rate character="A" />
<w class="mb-2" />
<rate character="好" />
```
5 changes: 3 additions & 2 deletions include/LCDesign/ui/components.h
Expand Up @@ -28,14 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef LCUIEX_UI_COMPONETS_H
#define LCUIEX_UI_COMPONETS_H
#ifndef LCDESIGN_UI_COMPONETS_H
#define LCDESIGN_UI_COMPONETS_H

#include <LCUI/gui/widget.h>
#include <LCDesign/ui/components/alert.h>
#include <LCDesign/ui/components/label.h>
#include <LCDesign/ui/components/icon.h>
#include <LCDesign/ui/components/img.h>
#include <LCDesign/ui/components/rate.h>
#include <LCDesign/ui/components/password.h>
#include <LCDesign/ui/components/typography.h>
#include <LCDesign/ui/components/modal.h>
Expand Down
46 changes: 46 additions & 0 deletions include/LCDesign/ui/components/rate.h
@@ -0,0 +1,46 @@
/*
* rate.h -- Rate component.
*
* Copyright (c) 2019, Liu chao <lc-soft@live.cn> All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of LCUI nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef LCDESIGN_RATE_H_
#define LCDESIGN_RATE_H_

void Rate_SetValue(LCUI_Widget w, unsigned value);

unsigned Rate_GetValue(LCUI_Widget w);

void Rate_SetCount(LCUI_Widget w, unsigned count);

void Rate_SetIcon(LCUI_Widget w, const char *void_icon, const char *icon);

void Rate_SetCharacter(LCUI_Widget w, const wchar_t ch);

void LCDesign_InitRate(void);

#endif
2 changes: 2 additions & 0 deletions main.vcxproj
Expand Up @@ -168,6 +168,7 @@
<ClCompile Include="src\ui\components\label.c" />
<ClCompile Include="src\ui\components\modal.c" />
<ClCompile Include="src\ui\components\password.c" />
<ClCompile Include="src\ui\components\rate.c" />
<ClCompile Include="src\ui\components\typography.c" />
<ClCompile Include="src\ui\dismiss.c" />
<ClCompile Include="src\ui\toggle.c" />
Expand All @@ -182,6 +183,7 @@
<ClInclude Include="include\LCDesign\ui\components\label.h" />
<ClInclude Include="include\LCDesign\ui\components\modal.h" />
<ClInclude Include="include\LCDesign\ui\components\password.h" />
<ClInclude Include="include\LCDesign\ui\components\rate.h" />
<ClInclude Include="include\LCDesign\ui\components\typography.h" />
<ClInclude Include="include\LCDesign\ui\dismiss.h" />
<ClInclude Include="include\LCDesign\ui\toggle.h" />
Expand Down
6 changes: 6 additions & 0 deletions main.vcxproj.filters
Expand Up @@ -54,6 +54,9 @@
<ClCompile Include="src\ui\components\img.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="src\ui\components\rate.c">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\LCDesign.h">
Expand Down Expand Up @@ -92,5 +95,8 @@
<ClInclude Include="include\LCDesign\ui\components\img.h">
<Filter>头文件\LCDesign\components</Filter>
</ClInclude>
<ClInclude Include="include\LCDesign\ui\components\rate.h">
<Filter>头文件\LCDesign\components</Filter>
</ClInclude>
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/main.c
Expand Up @@ -37,6 +37,7 @@ void LCDesign_Init(void)
LCDesign_InitLabel();
LCDesign_InitIcon();
LCDesign_InitImg();
LCDesign_InitRate();
LCDesign_InitPassword();
LCDesign_InitTypograhy();
LCDesign_InitModal();
Expand Down
15 changes: 15 additions & 0 deletions src/scss/_rate.scss
@@ -0,0 +1,15 @@
rate {
display: inline-block;

icon,
span {
font-size: $rate-star-size;
display: inline-block;
color: $rate-star-color;
margin-right: map-get($spacers, 2);
}
}

.rate-star-void {
color: $rate-star-void-color;
}
7 changes: 7 additions & 0 deletions src/scss/_variables.scss
Expand Up @@ -537,3 +537,10 @@ $list-group-action-active-bg: $gray-200 !default;
$close-font-size: $font-size-base * 1.5 !default;
$close-font-weight: $font-weight-bold !default;
$close-color: $black !default;


// Rate

$rate-star-size: $font-size-base * 1.5 !default;
$rate-star-color: $orange !default;
$rate-star-void-color: $gray-400 !default;
1 change: 1 addition & 0 deletions src/scss/lc-design.scss
Expand Up @@ -13,6 +13,7 @@
@import "buttons";
@import "dropdown";
@import "list-group";
@import "rate";
@import "close";
@import "modal";
@import "toasts";
Expand Down

0 comments on commit e036f13

Please sign in to comment.