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

Adds a "huggingface" button variant, and makes it the default for gr.LoginButton and gr.DuplicateButton #9254

Merged
merged 9 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
6 changes: 6 additions & 0 deletions .changeset/few-clowns-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/button": minor
"gradio": minor
---

feat:Adds a "clear" button variant, and makes it the default for `gr.LoginButton` and `gr.DuplicateButton`
4 changes: 2 additions & 2 deletions gradio/components/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(
*,
every: Timer | float | None = None,
inputs: Component | Sequence[Component] | set[Component] | None = None,
variant: Literal["primary", "secondary", "stop"] = "secondary",
variant: Literal["primary", "secondary", "stop", "clear"] = "secondary",
size: Literal["sm", "lg"] | None = None,
icon: str | None = None,
link: str | None = None,
Expand All @@ -46,7 +46,7 @@ def __init__(
value: Default text for the button to display. If callable, the function will be called whenever the app loads to set the initial value of the component.
every: Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.
inputs: Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.
variant: 'primary' for main call-to-action, 'secondary' for a more subdued style, 'stop' for a stop button.
variant: 'primary' for main call-to-action, 'secondary' for a more subdued style, 'stop' for a stop button, 'clear' for no background color.
size: Size of the button. Can be "sm" or "lg".
icon: URL or path to the icon file to display within the button. If None, no icon will be displayed.
link: URL to open when the button is clicked. If None, no link will be used.
Expand Down
2 changes: 1 addition & 1 deletion gradio/components/duplicate_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(
*,
every: Timer | float | None = None,
inputs: Component | Sequence[Component] | set[Component] | None = None,
variant: Literal["primary", "secondary", "stop"] = "secondary",
variant: Literal["primary", "secondary", "stop", "clear"] = "clear",
size: Literal["sm", "lg"] | None = "sm",
icon: str | None = None,
link: str | None = None,
Expand Down
4 changes: 2 additions & 2 deletions gradio/components/login_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(
*,
every: Timer | float | None = None,
inputs: Component | Sequence[Component] | set[Component] | None = None,
variant: Literal["primary", "secondary", "stop"] = "secondary",
variant: Literal["primary", "secondary", "stop", "clear"] = "clear",
size: Literal["sm", "lg"] | None = None,
icon: str
| None = "https://huggingface.co/front/assets/huggingface_logo-noborder.svg",
Expand All @@ -44,7 +44,7 @@ def __init__(
elem_classes: list[str] | str | None = None,
render: bool = True,
key: int | str | None = None,
scale: int | None = 0,
scale: int | None = None,
min_width: int | None = None,
):
"""
Expand Down
7 changes: 6 additions & 1 deletion js/button/shared/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export let elem_id = "";
export let elem_classes: string[] = [];
export let visible = true;
export let variant: "primary" | "secondary" | "stop" = "secondary";
export let variant: "primary" | "secondary" | "stop" | "clear" = "secondary";
export let size: "sm" | "lg" = "lg";
export let value: string | null = null;
export let link: string | null = null;
Expand Down Expand Up @@ -120,6 +120,11 @@
color: var(--button-secondary-text-color);
}

.clear {
border: var(--button-border-width) solid
var(--button-secondary-border-color);
}

.secondary:hover,
.secondary[disabled] {
background: var(--button-secondary-background-fill-hover);
Expand Down
Loading