Skip to content

Commit

Permalink
input-rating light
Browse files Browse the repository at this point in the history
  • Loading branch information
tborychowski committed Sep 23, 2023
1 parent 90f9bb2 commit 6d9ca84
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 114 deletions.
20 changes: 15 additions & 5 deletions docs-src/components/input/input-rating/InputRating.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@
<br>

<h3>Normal</h3>
<InputRating on:keydown="{onkey}" bind:value="{item.datevalue}"/>
{item.datevalue || ''}
<InputRating on:keydown="{onkey}" bind:value="{item.value}"/>
{item.value || ''}


<h3>Different symbol</h3>
<InputRating icon="circle" />


<h3>More stars</h3>
<InputRating max="10" />


<h3>Light (no background)</h3>
<InputRating light />


<h3>Label</h3>
<InputRating label="Pick one" />


<h3>Info</h3>
<InputRating label="Pick one" info="Pick your pick" />


<h3>Error</h3>
<InputRating
label="Pick one"
Expand All @@ -42,7 +49,7 @@ import { InputRating } from '../../../../src';
import { API } from '../../../api-table';
import { CodeExample } from '../../../code-example';
const item = {};
const item = { value: 2 };
const apiProps = [
{ name: 'class', type: 'string', description: 'Additional css class name to be added to the component container.' },
Expand All @@ -53,6 +60,7 @@ const apiProps = [
{ name: 'error', type: 'string', description: 'Error message to show above the input.' },
{ name: 'label', type: 'string', description: 'Label for the input.' },
{ name: 'labelOnTheLeft', type: ['true', 'false'], default: 'false', description: 'Put label to the left of the input (instead of at the top). Usually in longer forms, to align labels and inputs, hence input also gets <em>width: 100%</em>, as it will be constraint by the form container.' },
{ name: 'light', description: 'Disable background and border - for use cases other than in form context.<br>Light does not work when the input has error.' },
{ name: 'max', type: 'number', description: 'How many stars to show.' },
{ name: 'name', type: 'string', description: 'Assign title to the underlying input.' },
{ name: 'required', description: 'Mark the input as <i>required</i> for form submission and effectively shows it as invalid, until checked.' },
Expand All @@ -65,11 +73,13 @@ const apiProps = [
];
const exampleHtml = `
<InputDate on:change="{ onChange }" />
<InputRating on:change="{ onChange }" bind:value="{value}" />
<script>
let value = 4;
function onChange (e) {
console.log(e.detail.value);
const val = e.detail;
console.log(val);
}
&lt;/script>
Expand Down
204 changes: 103 additions & 101 deletions docs/docs.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/docs.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ui.css

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/input/input-rating/InputRating.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.input-rating { min-width: fit-content; }

.input-rating .input-inner,
.input-rating .input-inner:focus { outline: none; }
.input-rating input { position: absolute; visibility: hidden; }

.input-rating .input-row {
align-items: stretch;
Expand Down Expand Up @@ -33,6 +33,7 @@

.input-rating .button.button-link,
.input-rating .button.button-link:focus-visible,
.input-rating .button.button-link:hover {
text-decoration: none;
}
.input-rating .button.button-link:hover { text-decoration: none; }

.input-rating.light:not(.has-error) .input-inner,
.input-rating.light:not(.has-error) .input-row { background-color: transparent; border: none; }
6 changes: 3 additions & 3 deletions src/input/input-rating/InputRating.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class="input input-rating {className}"
class:has-error="{error}"
class:label-on-the-left="{labelOnTheLeft === true || labelOnTheLeft === 'true'}"
class:light
bind:this="{element}">

<Label {label} {disabled} for="{_id}"/>
Expand Down Expand Up @@ -41,9 +42,7 @@
on:mouseout="{() => highlighted = 0}"
on:click="{reset}"/>
<input
type="number"
autocomplete="off"
inert="true"
type="hidden"
{name}
{disabled}
id="{_id}"
Expand Down Expand Up @@ -84,6 +83,7 @@ export let info = undefined;
export let labelOnTheLeft = false;
export let max = 5;
export let icon = 'star';
export let light = undefined;
export let element = undefined;
export let inputElement = undefined;
Expand Down

0 comments on commit 6d9ca84

Please sign in to comment.