FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(Badge): Convert badge to typescript by jessiehuff · Pull Request #2048 · patternfly/patternfly-react · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) .md  (1) .snap  (1) .ts  (6) .tsx  (3) All 5 file types selected
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
      • Badge.d.ts
      • Badge.js
      • Badge.md
      • Badge.test.tsx
      • Badge.tsx
        • Badge.test.tsx.snap
      • index.d.ts
      • index.js
      • index.ts
        • badge.spec.ts
        • Demos.ts
            • BadgeDemo.tsx
          • index.ts

This file was deleted.

This file was deleted.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: 'Badge'
cssPrefix: 'pf-c-badge'
typescript: true
---
import { Badge } from '@patternfly/react-core';

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Badge from './Badge';
import { Badge } from './Badge';
import React from 'react';
import { shallow } from 'enzyme';

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/patternfly/components/Badge/badge.css';

export interface BadgeProps extends React.HTMLProps<HTMLSpanElement> {
/** Adds styling to the badge to indicate it has been read */
isRead?: boolean;
/** content rendered inside the Badge */
children?: React.ReactNode;
/** additional classes added to the Badge */
className?: string;
}

export const Badge: React.FunctionComponent<BadgeProps> = ({
isRead = false,
className = '',
children = '',
...props }: BadgeProps) => (
<span {...props} className={css(styles.badge, (isRead ? styles.modifiers.read : styles.modifiers.unread) as any, className)}>
{children}
</span>
);

This file was deleted.

This file was deleted.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Badge';
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('Badge Demo Test', () => {
it('Navigate to demo section', () => {
cy.visit('http://localhost:3000/');
cy.get('#badge-demo-nav-item-link').click();
cy.url().should('eq', 'http://localhost:3000/badge-demo-nav-link');
});

it('Verify badge is unread', () => {
cy.get('.pf-c-badge').should('have.class', 'pf-m-unread')
});

it('Verify default badge', () => {
cy.get('.pf-c-badge').contains('7')
});
})
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export const Demos: DemoInterface[] = [
name: 'Avatar Demo',
componentType: Examples.AvatarDemo
},
{
id: 'badge-demo',
name: 'Badge Demo',
componentType: Examples.BadgeDemo
},
{
id: 'brand-demo',
name: 'Brand Demo',
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { Badge } from '@patternfly/react-core';

export class BadgeDemo extends React.Component {
render() {
return (
<React.Fragment>
<Badge isRead={false}>7</Badge>
<Badge isRead={false}>24</Badge>
<Badge isRead={false}>240</Badge>
<Badge isRead={false}>999+</Badge>
</React.Fragment>
)
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './AlertDemo/AlertDemo';
export * from './AvatarDemo/AvatarDemo';
export * from './BadgeDemo/BadgeDemo';
export * from './BrandDemo/BrandDemo';
export * from './BreadcrumbDemo/BreadcrumbDemo';
export * from './ButtonDemo/ButtonDemo';
Expand Down

Back | FazBrowse Home | New Git URL