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

Va-minimal-footer: add component #937

Merged
merged 17 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
Copy link
Contributor

@jamigibbs jamigibbs Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we have to manually add this image here to the Storybook assets? Or was it moved by the build script? I noticed that there is a PNG and an SVG version in web-components/src/assets but here it's just the PNG.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamigibbs I removed the .png since it's not being used

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions packages/storybook/stories/va-minimal-footer.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { getWebComponentDocs, propStructure, StoryDocs } from './wc-helpers';

const minimalFooterDocs = getWebComponentDocs('va-minimal-footer');

export default {
title: 'Components/Minimal Footer',
id: 'components/va-minimal-footer',
parameters: {
componentSubtitle: `va-minimal-footer web component`,
docs: {
page: () => <StoryDocs data={minimalFooterDocs} />,
},
},
};

const Template = () => {
Copy link
Contributor

@jamigibbs jamigibbs Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component story isn't displaying in the code example:

Screenshot 2023-11-07 at 10 43 49 AM

I think to fix this you'll need to pass in an empty object to story like this:

https://github.com/department-of-veterans-affairs/component-library/blob/main/packages/storybook/stories/va-need-help.stories.jsx#L18-L20

return (
<va-minimal-footer />
);
};

export const Default = Template.bind(null);
Default.argTypes = propStructure(minimalFooterDocs);
Binary file added packages/web-components/assets/va-logo-white.png
Copy link
Contributor

@jamigibbs jamigibbs Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same also here. There is a PNG and an SVG version in web-components/src/assets but here it's just the PNG.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamigibbs I removed the .png since it's not being used

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@it-harrison There are a couple of other places that a .png file exists still. Do we want these removed as well?

Screenshot 2023-11-08 at 9 42 16 AM

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/web-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@department-of-veterans-affairs/web-components",
"version": "4.47.0",
"version": "4.48.0",
"description": "Stencil Component Starter",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/web-components/src/assets/va-logo-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/web-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ export namespace Components {
*/
"value"?: string;
}
interface VaMinimalFooter {
}
interface VaMinimalHeader {
"header"?: string;
"subheader"?: string;
Expand Down Expand Up @@ -1549,6 +1551,12 @@ declare global {
prototype: HTMLVaMemorableDateElement;
new (): HTMLVaMemorableDateElement;
};
interface HTMLVaMinimalFooterElement extends Components.VaMinimalFooter, HTMLStencilElement {
}
var HTMLVaMinimalFooterElement: {
prototype: HTMLVaMinimalFooterElement;
new (): HTMLVaMinimalFooterElement;
};
interface HTMLVaMinimalHeaderElement extends Components.VaMinimalHeader, HTMLStencilElement {
}
var HTMLVaMinimalHeaderElement: {
Expand Down Expand Up @@ -1722,6 +1730,7 @@ declare global {
"va-loading-indicator": HTMLVaLoadingIndicatorElement;
"va-maintenance-banner": HTMLVaMaintenanceBannerElement;
"va-memorable-date": HTMLVaMemorableDateElement;
"va-minimal-footer": HTMLVaMinimalFooterElement;
"va-minimal-header": HTMLVaMinimalHeaderElement;
"va-modal": HTMLVaModalElement;
"va-need-help": HTMLVaNeedHelpElement;
Expand Down Expand Up @@ -2424,6 +2433,8 @@ declare namespace LocalJSX {
*/
"value"?: string;
}
interface VaMinimalFooter {
}
interface VaMinimalHeader {
"header"?: string;
"subheader"?: string;
Expand Down Expand Up @@ -3274,6 +3285,7 @@ declare namespace LocalJSX {
"va-loading-indicator": VaLoadingIndicator;
"va-maintenance-banner": VaMaintenanceBanner;
"va-memorable-date": VaMemorableDate;
"va-minimal-footer": VaMinimalFooter;
"va-minimal-header": VaMinimalHeader;
"va-modal": VaModal;
"va-need-help": VaNeedHelp;
Expand Down Expand Up @@ -3327,6 +3339,7 @@ declare module "@stencil/core" {
"va-loading-indicator": LocalJSX.VaLoadingIndicator & JSXBase.HTMLAttributes<HTMLVaLoadingIndicatorElement>;
"va-maintenance-banner": LocalJSX.VaMaintenanceBanner & JSXBase.HTMLAttributes<HTMLVaMaintenanceBannerElement>;
"va-memorable-date": LocalJSX.VaMemorableDate & JSXBase.HTMLAttributes<HTMLVaMemorableDateElement>;
"va-minimal-footer": LocalJSX.VaMinimalFooter & JSXBase.HTMLAttributes<HTMLVaMinimalFooterElement>;
"va-minimal-header": LocalJSX.VaMinimalHeader & JSXBase.HTMLAttributes<HTMLVaMinimalHeaderElement>;
"va-modal": LocalJSX.VaModal & JSXBase.HTMLAttributes<HTMLVaModalElement>;
"va-need-help": LocalJSX.VaNeedHelp & JSXBase.HTMLAttributes<HTMLVaNeedHelpElement>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { newE2EPage } from '@stencil/core/testing';

describe('va-minimal-footer', () => {
it('renders', async () => {
const page = await newE2EPage();
await page.setContent('<va-minimal-footer></va-minimal-footer>');

const element = await page.find('va-minimal-footer');
expect(element).toHaveClass('hydrated');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { newSpecPage } from '@stencil/core/testing';
import { VAMinimalFooter } from '../va-minimal-footer';

describe('va-minimal-footer', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a unit test at all for this component? I think we can accomplish the same thing that you're doing here with an e2e test like this:

https://github.com/department-of-veterans-affairs/component-library/blob/main/packages/web-components/src/components/va-button/test/va-button.e2e.ts#L5-L18

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamigibbs I included the unit test here because the similar e2e test required putting the entire base 64 encoded svg in the test which made it unwieldy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thank you!

it('renders', async () => {
const page = await newSpecPage({
components: [VAMinimalFooter],
html: `<va-minimal-footer />`,
});
expect(page.root).toEqualHtml(`
<va-minimal-footer>
<mock:shadow-root>
<div class="va-footer">
<a href="/">
<img alt="VA.gov home" class="va-logo" src="[object Object]">
</a>
</div>
</mock:shadow-root>
</va-minimal-footer>
`);
});

});
danbrady marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.va-footer {
margin-left: auto;
margin-right: auto;
max-width: 1000px;
background-color: var(--color-primary-darkest);
padding: 10px 8px;

img.va-logo {
width: 200px;
}

@media (min-width: 481px) {
padding: 10px 16px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, Host, h } from '@stencil/core';
import vaSeal from '../../assets/va-logo-white.svg';

/**
* @componentName Minimal Footer
* @maturityCategory caution
* @maturityLevel candidate
*/

@Component({
tag: 'va-minimal-footer',
styleUrl: 'va-minimal-footer.scss',
shadow: true,
})
export class VAMinimalFooter {

render() {

return (
<Host>
<div class="va-footer">
<a href="/" >
<img class="va-logo" src={vaSeal} alt="VA.gov home"/>
</a>
</div>
</Host>
);
}
}
6 changes: 3 additions & 3 deletions packages/web-components/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<style type="text/css" media="screen">
body {
/* For a little breathing room around the components */
padding: 4rem;
/* padding: 4rem; */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to revert this change too?

}
</style>

</head>
<body>
<my-component first="Stencil" last="'Don't call me a framework' JS"></my-component>
</body>
<va-minimal-footer />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why this file was changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ug, accidentally committed!

</body>
</html>