Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typeable value on gradio.Slider #2329

Merged
merged 5 commits into from
Sep 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions ui/packages/form/src/Range.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { BlockTitle } from "@gradio/atoms";
import { create_classes } from "@gradio/utils";
import { get_styles } from "@gradio/utils";
import type { Styles } from "@gradio/utils";

export let value: number = 0;
Expand All @@ -18,20 +18,26 @@
export let show_label: boolean;

const id = `range_id_${_id++}`;

const dispatch = createEventDispatcher<{ change: number }>();

$: dispatch("change", value);
$: ({ classes } = get_styles(style, ["rounded", "border"]));
</script>

<div class="w-full flex flex-col ">
<div class="flex justify-between">
<label for={id}>
<BlockTitle {show_label}>{label}</BlockTitle>
</label>
<div class={"font-medium dark:text-gray-300" + create_classes(style)}>
{value}
</div>
<input
type="number"
class="gr-box gr-input gr-text-input text-center h-6 {classes}"
bind:value
min={minimum}
max={maximum}
{step}
{disabled}
/>
</div>
</div>

Expand Down