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

[PLAY-1702] Circle Icon Button Kit: Add Target Prop #4054

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type CircleIconButtonProps = {
onClick?: React.MouseEventHandler<HTMLElement>,
newWindow?: boolean,
type?: 'button' | 'submit' | 'reset' | undefined,
target?: string
variant?: 'primary' | 'secondary' | 'link',
}

Expand All @@ -36,6 +37,7 @@ const CircleIconButton = (props: CircleIconButtonProps): React.ReactElement => {
loading = false,
onClick = noop,
type,
target,
link,
newWindow,
variant,
Expand Down Expand Up @@ -66,6 +68,7 @@ const CircleIconButton = (props: CircleIconButtonProps): React.ReactElement => {
loading={loading}
newWindow={newWindow}
onClick={onClick}
target={target}
text={null}
variant={variant}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= pb_content_tag do %>
<%= pb_rails("button", props: {type: object.type, loading: object.loading, link: object.link, new_window:object.new_window, variant: object.variant, disabled: object.disabled, dark: object.dark}) do %>
<%= pb_rails("button", props: {type: object.type, loading: object.loading, link: object.link, new_window:object.new_window, variant: object.variant, target: object.target, disabled: object.disabled, dark: object.dark}) do %>
<%= pb_rails("icon", props: {icon: object.icon, fixed_width: true, dark: object.dark}) %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CircleIconButton < Playbook::KitBase
prop :link
prop :new_window, type: Playbook::Props::Boolean,
default: false
prop :target
def classname
generate_classname("pb_circle_icon_button_kit")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@
link: "https://google.com",
new_window: true
}) %>
<br/>
<%= pb_rails("circle_icon_button", props: {
icon: "info",
variant: "secondary",
aria: { label: "Link to Playbook in new window" },
link: "https://playbook.powerapp.cloud/",
target: "child"
}) %>
nidaqg marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ const CircleIconButtonLink = (props) => (
{...props}
/>

<br/>

<CircleIconButton
aria={{ label: "Link to Playbook in new window" }}
icon="info"
link="https://playbook.powerapp.cloud/"
target="child"
variant="secondary"
/>
</div>
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The `link` prop accepts a string that is used as an href value and causes the button to act as a link. The default behavior of a link is to open in the current window. You can optionally alter the link behavior by adding the `newWindow` prop (boolean), which will open the link in a new window, or by calling the `target` prop, which accepts `_self`, `_blank`, `_parent`, `_top`, `child`, or any string, allowing you to specify any link target.
Loading