Skip to content

Commit

Permalink
Add interactive args to gr.ColorPicker (#5118)
Browse files Browse the repository at this point in the history
* add interactive args to colorpicker

* add changeset

* add changeset

* add colorpicker stories

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
hannahblair and gradio-pr-bot committed Aug 7, 2023
1 parent 34f6b22 commit 1b017e6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/fluffy-ties-sink.md
@@ -0,0 +1,6 @@
---
"@gradio/colorpicker": patch
"gradio": patch
---

fix:Add `interactive` args to `gr.ColorPicker`
30 changes: 30 additions & 0 deletions js/colorpicker/ColorPicker.stories.svelte
@@ -0,0 +1,30 @@
<script>
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
import ColorPicker from "./static/StaticColorpicker.svelte";
</script>

<Meta title="Components/Color Picker" component={ColorPicker} argTypes={{}} />

<Template let:args>
<ColorPicker value="Color Picker" {...args} />
</Template>

<Story name="Default" />
<Story
name="Color Picker with a color value and hidden label"
args={{ value: "#FFC0CB", show_label: false }}
/>
<Story
name="Color Picker with a color value and label"
args={{ value: "#FFC0CB", label: "This is a neat color" }}
/>

<Story
name="Disabled color picker"
args={{ value: "#FFC0CB", interactive: false }}
/>

<Story
name="Color Picker with a color value and info"
args={{ value: "#FFC0CB", info: "This is a neat color" }}
/>
3 changes: 3 additions & 0 deletions js/colorpicker/index.svelte
Expand Up @@ -19,6 +19,7 @@
export let min_width: number | undefined = undefined;
export let loading_status: LoadingStatus;
export let mode: "static" | "dynamic";
export let interactive: boolean;
</script>

{#if mode === "static"}
Expand All @@ -35,6 +36,7 @@
{scale}
{min_width}
{loading_status}
{interactive}
on:change
on:input
on:submit
Expand All @@ -55,6 +57,7 @@
{scale}
{min_width}
{loading_status}
{interactive}
on:change
on:input
on:submit
Expand Down
3 changes: 2 additions & 1 deletion js/colorpicker/interactive/InteractiveColorpicker.svelte
Expand Up @@ -18,6 +18,7 @@
export let scale: number | null = null;
export let min_width: number | undefined = undefined;
export let loading_status: LoadingStatus;
export let interactive = true;
</script>

<Block {visible} {elem_id} {elem_classes} {container} {scale} {min_width}>
Expand All @@ -29,11 +30,11 @@
{label}
{info}
{show_label}
disabled={!interactive}
on:change
on:input
on:submit
on:blur
on:focus
disabled
/>
</Block>
3 changes: 2 additions & 1 deletion js/colorpicker/static/StaticColorpicker.svelte
Expand Up @@ -18,6 +18,7 @@
export let scale: number | null = null;
export let min_width: number | undefined = undefined;
export let loading_status: LoadingStatus;
export let interactive = true;
</script>

<Block {visible} {elem_id} {elem_classes} {container} {scale} {min_width}>
Expand All @@ -29,11 +30,11 @@
{label}
{info}
{show_label}
disabled={!interactive}
on:change
on:input
on:submit
on:blur
on:focus
disabled
/>
</Block>

1 comment on commit 1b017e6

@vercel
Copy link

@vercel vercel bot commented on 1b017e6 Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.