Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Commit

Permalink
feat(Input): added disabled and readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
TheComputerM committed Aug 27, 2020
1 parent 0df6d8b commit 1531349
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
25 changes: 25 additions & 0 deletions packages/docs/src/examples/components/textField/disabled.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script>
import TextField from "svelte-materialify/src/components/TextField";
import { Row, Col } from "svelte-materialify/src/components/Grid";
</script>

<Row>
<Col>
<TextField disabled value="Hello">Regular</TextField>
<br />
<TextField disabled filled value="Hello">Filled</TextField>
<br />
<TextField disabled outlined value="Hello">Outlined</TextField>
<br />
<TextField disabled solo value="Hello" />
</Col>
<Col>
<TextField readonly value="Hello">Regular</TextField>
<br />
<TextField readonly filled value="Hello">Filled</TextField>
<br />
<TextField readonly outlined value="Hello">Outlined</TextField>
<br />
<TextField readonly solo value="Hello" />
</Col>
</Row>
6 changes: 6 additions & 0 deletions packages/docs/src/routes/components/text-field.svx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ Text fields components are used for collecting user provided information.
<Example code={examples.dense} component={Examples.dense} />


### Disabled and Readonly

<Example code={examples.disabled} component={Examples.disabled} />


### Icons

<Example code={examples.icons} component={Examples.icons} />


### Clearable

<Example code={examples.clearable} component={Examples.clearable} />
8 changes: 8 additions & 0 deletions packages/svelte-materialify/src/components/Input/Input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@
textarea {
color: var(--theme-text-disabled);
}

.s-icon {
color: var(--theme-icons-inactive);
}

label {
color: var(--theme-text-disabled);
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions packages/svelte-materialify/src/components/Input/Input.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script>
let classes = '';
let classes = "";
export { classes as class };
export let color = null;
export let readonly = false;
export let disabled = false;
export let messages = [];
</script>
Expand All @@ -10,7 +11,11 @@
</style>

<div class="s-input {classes}" class:disabled style="--input-active-color:{color}">
<div
class="s-input {classes}"
class:readonly
class:disabled
style="--input-active-color:{color}">
<slot name="prepend" />
<div class="s-input__control">
<slot />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<script context="module">
import uid from 'uid';
const clearIcon = 'M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z';
import uid from "uid";
const clearIcon =
"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";
</script>

<script>
import Input from '../Input';
import Icon from '../Icon';
import Input from "../Input";
import Icon from "../Icon";
export let value = '';
export let value = "";
export let color = null;
export let filled = false;
export let solo = false;
Expand All @@ -16,8 +18,8 @@
export let dense = false;
export let rounded = false;
export let clearable = false;
// export let disabled = false;
// export let readonly = false;
export let readonly = false;
export let disabled = false;
export let placeholder = null;
// export let helper = "";
export let id = null;
Expand All @@ -34,7 +36,7 @@
}
function clear() {
value = '';
value = "";
if (!placeholder) labelActive = false;
}
</script>
Expand All @@ -43,7 +45,7 @@
</style>

<Input class="s-text-field" {color}>
<Input class="s-text-field" {color} {readonly} {disabled}>
<div slot="prepend">
<slot name="prepend-outer" />
</div>
Expand All @@ -65,6 +67,7 @@
bind:value
{placeholder}
{id}
{disabled}
on:focus={onFocus}
on:blur={onBlur} />
</div>
Expand Down

0 comments on commit 1531349

Please sign in to comment.