Skip to content

Commit

Permalink
[DEV-11239] Prevent button render if no href, updated classname to ma…
Browse files Browse the repository at this point in the history
…tch layout
  • Loading branch information
fgyimah committed Aug 11, 2023
1 parent c539bb1 commit d88258e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/elements/ButtonBlock/ButtonBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ interface ButtonNodeProps {
export function ButtonBlock({ node }: ButtonNodeProps) {
const { href, label, layout, new_tab: newTab, variant } = node;

if (!href) {
return null;
}

return (
<a
className={classNames('prezly-slate-button-block', {
'prezly-slate-button-block--disabled': !href,
'prezly-slate-button-block--outlined': variant === ButtonBlockNode.Variant.OUTLINE,
'prezly-slate-button-block--fullWidth': layout === ButtonBlockNode.Layout.WIDE,
'prezly-slate-button-block--wide': layout === ButtonBlockNode.Layout.WIDE,
'prezly-slate-button-block--right': layout === ButtonBlockNode.Layout.RIGHT,
'prezly-slate-button-block--left': layout === ButtonBlockNode.Layout.LEFT,
'prezly-slate-button-block--center': layout === ButtonBlockNode.Layout.CENTER,
Expand Down
7 changes: 1 addition & 6 deletions src/elements/ButtonBlock/ButtonBlockNode.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@ $white: #fff;
line-height: $line-height;
font-weight: 600;

&--disabled {
opacity: 0.5;
cursor: not-allowed;
}

&--outlined {
background-color: $white;
color: $color-text;
border: 1px solid $color-border;
}

&--fullWidth {
&--wide {
width: auto;
}

Expand Down

0 comments on commit d88258e

Please sign in to comment.