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: adding hideCloseButton prop to cv-inline-notification #1233

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
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CvInlineNotification should not render close button when hideCloseButton is true 1`] = `
<div data-notification="" role="alert" class="cv-inline-notification bx--inline-notification bx--inline-notification--error">
<div class="bx--inline-notification__details">
<anonymous-stub class="bx--inline-notification__icon"></anonymous-stub>
<div class="bx--inline-notification__text-wrapper">
<p class="bx--inline-notification__title"></p>
<p class="bx--inline-notification__subtitle"></p>
</div>
</div> <button type="button" class="bx--inline-notification__action-button bx--btn bx--btn--sm bx--btn--ghost">
test action label
</button>
<!---->
</div>
`;

exports[`CvInlineNotification should not render close button when hideCloseButton is true 2`] = `
<div data-notification="" aria-live="polite" class="cv-inline-notification bx--inline-notification bx--inline-notification--info">
<div class="bx--inline-notification__details">
<anonymous-stub class="bx--inline-notification__icon"></anonymous-stub>
<div class="bx--inline-notification__text-wrapper">
<p class="bx--inline-notification__title"></p>
<p class="bx--inline-notification__subtitle"></p>
</div>
</div> <button type="button" class="bx--inline-notification__action-button bx--btn bx--btn--sm bx--btn--ghost">
test action label
</button>
<!---->
</div>
`;

exports[`CvInlineNotification should not render close button when hideCloseButton is true 3`] = `
<div data-notification="" role="alert" class="cv-inline-notification bx--inline-notification bx--inline-notification--warning">
<div class="bx--inline-notification__details">
<anonymous-stub class="bx--inline-notification__icon"></anonymous-stub>
<div class="bx--inline-notification__text-wrapper">
<p class="bx--inline-notification__title"></p>
<p class="bx--inline-notification__subtitle"></p>
</div>
</div> <button type="button" class="bx--inline-notification__action-button bx--btn bx--btn--sm bx--btn--ghost">
test action label
</button>
<!---->
</div>
`;

exports[`CvInlineNotification should not render close button when hideCloseButton is true 4`] = `
<div data-notification="" aria-live="polite" class="cv-inline-notification bx--inline-notification bx--inline-notification--success">
<div class="bx--inline-notification__details">
<anonymous-stub class="bx--inline-notification__icon"></anonymous-stub>
<div class="bx--inline-notification__text-wrapper">
<p class="bx--inline-notification__title"></p>
<p class="bx--inline-notification__subtitle"></p>
</div>
</div> <button type="button" class="bx--inline-notification__action-button bx--btn bx--btn--sm bx--btn--ghost">
test action label
</button>
<!---->
</div>
`;

exports[`CvInlineNotification should render correctly 1`] = `
<div data-notification="" role="alert" class="cv-inline-notification bx--inline-notification bx--inline-notification--error">
<div class="bx--inline-notification__details">
Expand Down
11 changes: 10 additions & 1 deletion packages/core/__tests__/cv-inline-notification.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('CvInlineNotification', () => {
// ***************
// PROP CHECKS
// ***************
testComponent.propsAreType(CvInlineNotification, ['lowContrast'], Boolean);
testComponent.propsAreType(CvInlineNotification, ['lowContrast', 'hideCloseButton'], Boolean);
testComponent.propsAreType(CvInlineNotification, ['actionLabel', 'closeAriaLabel', 'kind'], String);
testComponent.propsHaveDefault(CvInlineNotification, ['closeAriaLabel', 'kind', 'actionLabel']);

Expand Down Expand Up @@ -56,6 +56,15 @@ describe('CvInlineNotification', () => {
}
});

it('should not render close button when hideCloseButton is true', async () => {
const propsData = { lowContrast: false, kind: '', actionLabel: 'test action label', hideCloseButton: true };
for (const kind of kinds) {
propsData.kind = kind;
const wrapper = await shallow(CvInlineNotification, { propsData });
expect(wrapper.html()).toMatchSnapshot();
}
});

// ***************
// FUNCTIONAL TESTS
// ***************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
{{ actionLabel }}
</button>
<button
v-if="!hideCloseButton"
type="button"
:aria-label="closeAriaLabel"
data-notification-btn
Expand Down Expand Up @@ -66,6 +67,7 @@ export default {
validator: val => ['error', 'info', 'warning', 'success'].includes(val),
},
lowContrast: Boolean,
hideCloseButton: Boolean,
},
computed: {
icon() {
Expand Down
6 changes: 6 additions & 0 deletions storybook/stories/cv-inline-notification-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ const preKnobs = {
config: ['Low contrast', false],
prop: 'low-contrast',
},
hideCloseButton: {
group: 'attr',
type: boolean,
config: ['Hide close button', false],
prop: 'hide-close-button',
},
};

const variants = [
Expand Down