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

feat: eng-22373: enable floating buttons #212

Merged
merged 3 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/components/Button/BaseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const BaseButton: FC<InternalButtonProps> = React.forwardRef(
split,
splitButtonChecked = false,
splitButtonProps,
floatingButtonProps,
yzhang-eightfold marked this conversation as resolved.
Show resolved Hide resolved
style,
text,
theme,
Expand Down Expand Up @@ -82,6 +83,7 @@ export const BaseButton: FC<InternalButtonProps> = React.forwardRef(
{ [styles.pillShape]: shape === ButtonShape.Pill },
{ [styles.dropShadow]: dropShadow },
{ [styles.dark]: theme === ButtonTheme.dark },
{ [styles.floating]: floatingButtonProps?.enabled },
]);

const buttonBaseClassNames: string = mergeClasses([
Expand Down
3 changes: 3 additions & 0 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ const buttonArgs: Object = {
disabled: false,
disruptive: false,
dropShadow: false,
floatingButtonProps: {
enabled: false,
},
htmlType: 'button',
iconProps: {
path: IconName.mdiCardsHeart,
Expand Down
12 changes: 12 additions & 0 deletions src/components/Button/Button.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ export interface InternalButtonProps extends ButtonProps {
ref?: Ref<HTMLButtonElement>;
}

export interface FloatingButtonProps {
/**
* Determines if the button is floating.
* @default false
*/
enabled?: boolean;
}

export type NativeButtonProps = Omit<OcBaseProps<HTMLButtonElement>, 'type'>;

export interface SplitButtonProps
Expand Down Expand Up @@ -193,4 +201,8 @@ export interface ButtonProps extends NativeButtonProps {
* The button is a toggle button with distinct on and off states.
*/
toggle?: boolean;
/**
* The button is always floating on bottom right corner.
*/
floatingButtonProps?: FloatingButtonProps;
}
7 changes: 7 additions & 0 deletions src/components/Button/button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@
width: fit-content;
}

&.floating {
position: fixed;
bottom: 40px;
right: 40px;
z-index: $z-index-400;
dkilgore-eightfold marked this conversation as resolved.
Show resolved Hide resolved
}

&:disabled,
&.disabled {
opacity: $disabled-alpha-value;
Expand Down