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/disable modal close prop #323

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .github/workflows/design-library-deploy-storybook-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
app_location: "design-library/storybook-static"
skip_app_build: true
skip_api_build: true
skip_deploy_on_missing_secrets: true

close_pull_request:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
Expand Down
2 changes: 1 addition & 1 deletion design-library/src/components/BccModal/BccModal.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Template: StoryFn<typeof BccModal> = (args) => ({
});

/**
* Control the content of the modal with the `title` prop and the `default` slot. Pass buttons to the `primaryAction` and `secondaryAction` slots. Set `closeButton` to `false` to hide the close button on desktops. The modal emits a `close` event when the user clicks the close button or closes the modal by clicking outside of it or pressing Escape.
* Control the content of the modal with the `title` prop and the `default` slot. Pass buttons to the `primaryAction` and `secondaryAction` slots. Set `closeButton` to `false` to hide the close button on desktops. The modal emits a `close` event when the user clicks the close button or closes the modal by clicking outside of it or pressing Escape, unless `closeOnOutsideClick` is set to false.
*/
export const Example = Template.bind({});
Example.args = {
Expand Down
10 changes: 9 additions & 1 deletion design-library/src/components/BccModal/BccModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,30 @@ type Props = {
open: boolean;
title?: string;
closeButton?: boolean;
closeOnOutsideClick?: boolean;
};

const props = withDefaults(defineProps<Props>(), {
open: false,
closeButton: true,
closeOnOutsideClick: true,
});

const emit = defineEmits(["close"]);

const slots = useSlots();
const showCloseButton = computed(() => props.closeButton && !slots.header);

const handleClose = () => {
if (props.closeOnOutsideClick) {
emit("close");
}
};
</script>

<template>
<TransitionRoot as="template" :show="open">
<Dialog as="div" class="bcc-modal-overlay-wrapper" @close="emit('close')">
<Dialog as="div" class="bcc-modal-overlay-wrapper" @close="handleClose">
<div class="flex h-[100dvh] w-[100dvw] items-center justify-center overflow-hidden">
<TransitionChild
as="div"
Expand Down
Loading