Skip to content

Conversation

@jpuzz0 jpuzz0 changed the title chore(BackToTop/Backdrop/BackgroundImage/Badge/Banner/Brand/Breadcrumb): Convert examples from JS to TS chore: Convert examples from JS to TS Jan 13, 2022
@patternfly-build
Copy link
Collaborator

patternfly-build commented Jan 13, 2022

@jpuzz0 jpuzz0 changed the title chore: Convert examples from JS to TS chore: Convert examples to typescript Jan 13, 2022
import React from 'react';
import { Brand } from '@patternfly/react-core';

export const BrandBasic: React.FunctionComponent = () => <Brand src="./pfLogo.svg" alt="Patternfly Logo" />;
Copy link
Contributor

Choose a reason for hiding this comment

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

did it not work if you tried to import the svg? might be worth opening an issue if we have an issue with svg imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't support importing svg files at the moment (probably a tsconfig setting, possibly webpack config related), but importing the SVG didn't seem correct to begin with because src takes a string type (implying a path to a source, not the source itself), not an SVGElement or HTMLElement type.

I don't perceive it as an issue unless we need to import svg's somewhere. In this case we don't. Then there's the question of, do we really want to treat them as their own modules or do we just create function components that return JSX interpretations of the svg, which is another approach which wouldn't require any tsconfig/webpack changes.

Copy link
Contributor Author

@jpuzz0 jpuzz0 Jan 19, 2022

Choose a reason for hiding this comment

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

Looking into this further, the default import of an SVG element returns a string, so a module file was added to accommodate for typescript not recognizing SVG imports as modules (index.d.ts), and this example was reverted back to using that imported pfLogo.

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Looks great! Just one little nit.


export const BannerBasic: React.FunctionComponent = () => (
<Flex direction={{ default: 'column' }}>
<Banner>Default banner</Banner>
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually our examples match the core examples. For that reason, I would add back the <br />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. And updated other recent instances where I was using flexbox instead of breaks and empty spaces as well.

@jpuzz0 jpuzz0 force-pushed the chore/convert-examples-to-ts branch from e287bfc to ec9ca43 Compare January 20, 2022 20:12
Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Looks great!

@tlabaj tlabaj merged commit 68df206 into patternfly:main Jan 20, 2022
@patternfly-build
Copy link
Collaborator

Your changes have been released in:

  • eslint-plugin-patternfly-react@4.31.3
  • @patternfly/react-catalog-view-extension@4.43.3
  • @patternfly/react-charts@6.45.3
  • @patternfly/react-code-editor@4.33.3
  • @patternfly/react-console@4.43.3
  • @patternfly/react-core@4.192.3
  • @patternfly/react-docs@5.53.3
  • @patternfly/react-icons@4.43.3
  • @patternfly/react-inline-edit-extension@4.37.3
  • demo-app-ts@4.152.3
  • @patternfly/react-integration@4.154.3
  • @patternfly/react-log-viewer@4.37.3
  • @patternfly/react-styles@4.42.3
  • @patternfly/react-table@4.61.3
  • @patternfly/react-tokens@4.44.3
  • @patternfly/react-topology@4.39.3
  • @patternfly/react-virtualized-extension@4.39.3
  • transformer-cjs-imports@4.30.3

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants