Skip to content

Commit

Permalink
[PLAY-1702] Circle Icon Button Kit: Add Target Prop (#4054)
Browse files Browse the repository at this point in the history
Adds target prop for Circle Icon Button Kit. 

[[PLAY-1702]](https://runway.powerhrg.com/backlog_items/PLAY-1702)

#### Checklist:
- [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new
kit`, `deprecated`, or `breaking`. See [Changelog &
Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels)
for details.
- [x] **DEPLOY** I have added the `milano` label to show I'm ready for a
review.
  • Loading branch information
Lsimmons98 authored Dec 30, 2024
1 parent 16296a3 commit 4334289
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
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"
}) %>
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.

0 comments on commit 4334289

Please sign in to comment.