Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ yarn start --scope @zendeskgarden/react-buttons

All elements must

* Be implemented with associated `Conatiner` and `View` components
* Be implemented with associated `Container` and `View` components
* Provide `uncontrolled` and `controlled` state management if necessary
* Be implemented with the `ControlledComponent` state abstractions if necessary
* Create an abstraction to benefit a majority of use cases
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ install: yarn --frozen-lockfile

script:
- yarn lint
- yarn format
Copy link
Contributor

Choose a reason for hiding this comment

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

@jzempel What prompted this change?

I would be concerned if Travis was testing and deploying code that was transformed by a format without it being visible in Github.

Copy link
Member Author

Choose a reason for hiding this comment

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

We seem to continue to let non-formatted code slip through (misconfigured husky?). The travis build will fail if the git tree isn't clean after test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh that's perfect πŸ’―

- yarn test:all --coverage --runInBand

after_success: yarn coveralls < demo/coverage/lcov.info
Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ components are packaged and published individually, but combined under
this single repository. Components rely on [Garden
CSS](https://github.com/zendeskgarden/css-components) for styling.

Try out the Garden React Components in a mock product environment with CodeSandbox

[![Edit Garden Create-React-App](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/43nwpkn717)

## Installation

See the individual package README for the React component you would like
Expand All @@ -22,6 +18,7 @@ Package | Version | Dependencies
------- | ------- | ------------
[`@zendeskgarden/react-autocomplete`](packages/autocomplete) | [![npm version][autocomplete npm version]][autocomplete npm link] | [![Dependency Status][autocomplete dependency status]][autocomplete dependency link]
[`@zendeskgarden/react-avatars`](packages/avatars) | [![npm version][avatars npm version]][avatars npm link] | [![Dependency Status][avatars dependency status]][avatars dependency link]
[`@zendeskgarden/react-breadcrumbs`](packages/breadcrumbs) | [![npm version][breadcrumbs npm version]][breadcrumbs npm link] | [![Dependency Status][breadcrumbs dependency status]][breadcrumbs dependency link]
[`@zendeskgarden/react-buttons`](packages/buttons) | [![npm version][buttons npm version]][buttons npm link] | [![Dependency Status][buttons dependency status]][buttons dependency link]
[`@zendeskgarden/react-checkboxes`](packages/checkboxes) | [![npm version][checkboxes npm version]][checkboxes npm link] | [![Dependency Status][checkboxes dependency status]][checkboxes dependency link]
[`@zendeskgarden/react-chrome`](packages/chrome) | [![npm version][chrome npm version]][chrome npm link] | [![Dependency Status][chrome dependency status]][chrome dependency link]
Expand Down Expand Up @@ -54,6 +51,10 @@ Package | Version | Dependencies
[avatars npm link]: https://www.npmjs.com/package/@zendeskgarden/react-avatars
[avatars dependency status]: https://img.shields.io/david/zendeskgarden/react-components.svg?path=packages/avatars&style=flat-square
[avatars dependency link]: https://david-dm.org/zendeskgarden/react-components?path=packages/avatars
[breadcrumbs npm version]: https://img.shields.io/npm/v/@zendeskgarden/react-breadcrumbs.svg?style=flat-square
[breadcrumbs npm link]: https://www.npmjs.com/package/@zendeskgarden/react-breadcrumbs
[breadcrumbs dependency status]: https://img.shields.io/david/zendeskgarden/react-components.svg?path=packages/breadcrumbs&style=flat-square
[breadcrumbs dependency link]: https://david-dm.org/zendeskgarden/react-components?path=packages/breadcrumbs
[buttons npm version]: https://img.shields.io/npm/v/@zendeskgarden/react-buttons.svg?style=flat-square
[buttons npm link]: https://www.npmjs.com/package/@zendeskgarden/react-buttons
[buttons dependency status]: https://img.shields.io/david/zendeskgarden/react-components.svg?path=packages/buttons&style=flat-square
Expand Down Expand Up @@ -149,11 +150,11 @@ Package | Version | Dependencies

## Usage

Our packages are easily consumable with [create-react-app](https://github.com/facebook/create-react-app)
and standard webpack configs.

All packages follow a similar installation process. Below is an example of
consuming our [react-buttons](https://www.npmjs.com/package/@zendeskgarden/react-buttons)
Our packages are easily consumable with
[create-react-app](https://github.com/facebook/create-react-app)
and standard webpack configs. All packages follow a similar installation process.
Below is an example of consuming our
[react-buttons](https://www.npmjs.com/package/@zendeskgarden/react-buttons)
package.

### Install dependencies
Expand Down Expand Up @@ -194,6 +195,10 @@ class App extends Component {
render(<App />, document.getElementById('root'));
```

Try out Garden React components in a mock product environment.

[![Edit Garden Create-React-App](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/43nwpkn717)

## Contribution

Thanks for your interest in Garden! Community involvement helps make our
Expand Down
11 changes: 7 additions & 4 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ <h1 class="c-main__title">React Components</h1>
<div class="u-mb-sm">
<a class="u-fg-inherit" href="avatars">Avatars</a>
</div>
<div class="u-mb-sm">
<a class="u-fg-inherit" href="breadcrumbs">Breadcrumbs</a>
</div>
<div class="u-mb-sm">
<a class="u-fg-inherit" href="buttons">Buttons</a>
</div>
Expand All @@ -109,11 +112,11 @@ <h1 class="c-main__title">React Components</h1>
<div class="u-mb-sm">
<a class="u-fg-inherit" href="menus">Menus</a>
</div>
</div>
<div class="col-xl-4 col-sm-6">
<div class="u-mb-sm">
<a class="u-fg-inherit" href="modals">Modals</a>
</div>
</div>
<div class="col-xl-4 col-sm-6">
<div class="u-mb-sm">
<a class="u-fg-inherit" href="notifications">Notifications</a>
</div>
Expand All @@ -133,10 +136,10 @@ <h1 class="c-main__title">React Components</h1>
<a class="u-fg-inherit" href="selection">Selection</a>
</div>
<div class="u-mb-sm">
<a class="u-fg-inherit" href="tabs">Tabs</a>
<a class="u-fg-inherit" href="tables">Tables</a>
</div>
<div class="u-mb-sm">
<a class="u-fg-inherit" href="tables">Tables</a>
<a class="u-fg-inherit" href="tabs">Tabs</a>
</div>
</div>
<div class="col-xl-4 col-sm-6">
Expand Down
4 changes: 2 additions & 2 deletions packages/autocomplete/src/examples/multiselect.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ const MoreAnchor = styled(Anchor)`
style: Object.assign(
{ margin: '0 2px', flexGrow: 1, width: 60 },
Object.keys(state.selectedKeys).length !== 0 &&
(!state.isFocused || tagFocusedKey !== undefined) &&
!isOpen
(!state.isFocused || tagFocusedKey !== undefined) &&
!isOpen
? { opacity: 0, height: 0, minHeight: 0 }
: {}
)
Expand Down
1 change: 1 addition & 0 deletions packages/breadcrumbs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

37 changes: 37 additions & 0 deletions packages/breadcrumbs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# @zendeskgarden/react-breadcrumbs [![npm version](https://img.shields.io/npm/v/@zendeskgarden/react-breadcrumbs.svg?style=flat-square)](https://www.npmjs.com/package/@zendeskgarden/react-breadcrumbs)

This package includes components relating to breadcrumbs in the
[Garden Design System](https://zendeskgarden.github.io/).

## Installation

```sh
npm install @zendeskgarden/react-breadcrumbs

# Peer Dependencies - Also Required
npm install react react-dom prop-types styled-components @zendeskgarden/react-theming
```

## Usage

```jsx static
/**
* Include breadcrumbs styling at the root of your application
*/
import '@zendeskgarden/react-breadcrumbs/dist/styles.css';

import { ThemeProvider } from '@zendeskgarden/react-theming';
import { Breadcrumb, Item } from '@zendeskgarden/react-breadcrumbs';
import { Anchor } from '@zendeskgarden/react-buttons';

/**
* Place a `ThemeProvider` at the root of your React application
*/
<ThemeProvider>
<Breadcrumb>
<Anchor href="/">Root</Anchor>
<Anchor href="..">Parent</Anchor>
<Item>Self</Item>
</Breadcrumb>
</ThemeProvider>;
```
47 changes: 47 additions & 0 deletions packages/breadcrumbs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@zendeskgarden/react-breadcrumbs",
"description": "Components relating to breadcrumbs in the Garden Design System",
"license": "Apache-2.0",
"author": "Zendesk Garden <garden@zendesk.com>",
"homepage": "https://garden.zendesk.com/",
"repository": "https://github.com/zendeskgarden/react-components",
"bugs": {
"url": "https://github.com/zendeskgarden/react-components/issues"
},
"version": "0.0.0",
"main": "./dist/index.js",
"files": [
"dist"
],
"scripts": {
"build": "../../utils/scripts/build.sh",
"build:demo": "../../utils/scripts/build-demo.sh",
"start": "../../utils/scripts/start.sh"
},
"dependencies": {
"classnames": "^2.2.5"
},
"peerDependencies": {
"@zendeskgarden/react-theming": "^1.0.0 || ^2.0.0 || ^3.0.0",
"prop-types": "^15.6.1",
"react": "^0.14.0 || ^15.0.0 || ^16.0.0",
"react-dom": "^0.14.0 || ^15.0.0 || ^16.0.0",
"styled-components": "^3.2.6"
},
"devDependencies": {
"@zendeskgarden/css-breadcrumbs": "0.1.2",
"@zendeskgarden/react-theming": "^3.1.3",
"@zendeskgarden/react-utilities": "^0.2.2"
},
"keywords": [
"components",
"garden",
"react",
"zendesk"
],
"publishConfig": {
"access": "public"
},
"zendeskgarden:library": "GardenBreadcrumbs",
"zendeskgarden:src": "src/index.js"
}
20 changes: 20 additions & 0 deletions packages/breadcrumbs/src/containers/BreadcrumbContainer.example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
```jsx
const { Anchor } = require('@zendeskgarden/react-buttons/src');

<BreadcrumbContainer>
{({ getContainerProps }) => (
/* role not needed as `BreadcrumbView` is a navigation landmark. */
<BreadcrumbView {...getContainerProps({ role: null })}>
<List>
<Item>
<Anchor>One</Anchor>
</Item>
<Item>
<Anchor>Two</Anchor>
</Item>
<Item current>Three</Item>
</List>
</BreadcrumbView>
)}
</BreadcrumbContainer>;
```
39 changes: 39 additions & 0 deletions packages/breadcrumbs/src/containers/BreadcrumbContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright Zendesk, Inc.
*
* Use of this source code is governed under the Apache License, Version 2.0
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

import { Component } from 'react';
import PropTypes from 'prop-types';

export default class BreadcrumbContainer extends Component {
static propTypes = {
/**
* @param {Object} renderProps
* @param {Function} renderProps.getContainerProps - Props to be spread onto containing element
*/
children: PropTypes.func,
/**
* Identical to children
*/
render: PropTypes.func
};

getContainerProps = ({ role = 'navigation', ...other } = {}) => {
return {
role,
'aria-label': 'Breadcrumb navigation',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we default this like role in the argument destructuring to make it more obvious to teams that they'll need to translate this? Should we mention in the readme example that we hard code an english value?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we default this like role in the argument destructuring to make it more obvious to teams that they'll need to translate this?

Not sure how clean this would be since we would be destructuring a hyphenated value?

Should we mention in the readme example that we hard code an english value?

Definitely.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ryanseddon I added copy to the element example about expected override. But I don't think I can move 'aria-label' into the destructured parameter list as it's an invalid property name.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh yeah good point

...other
};
};

render() {
const { children, render = children } = this.props;

return render({
getContainerProps: this.getContainerProps
});
}
}
34 changes: 34 additions & 0 deletions packages/breadcrumbs/src/containers/BreadcrumbContainer.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright Zendesk, Inc.
*
* Use of this source code is governed under the Apache License, Version 2.0
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

import React from 'react';
import { mountWithTheme } from '@zendeskgarden/react-testing';

import BreadcrumbContainer from './BreadcrumbContainer';

describe('BreadcrumbContainer', () => {
let wrapper;

beforeEach(() => {
wrapper = mountWithTheme(
<BreadcrumbContainer>
{({ getContainerProps }) => <div {...getContainerProps({ 'data-test-id': 'container' })} />}
</BreadcrumbContainer>
);
});

const findContainer = enzymeWrapper => enzymeWrapper.find('[data-test-id="container"]');

describe('getContainerProps()', () => {
it('applies correct accessibility attributes', () => {
const container = findContainer(wrapper);

expect(container).toHaveProp('role', 'navigation');
expect(container).toHaveProp('aria-label', 'Breadcrumb navigation');
});
});
});
14 changes: 14 additions & 0 deletions packages/breadcrumbs/src/elements/Breadcrumb.example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The `Breadcrumb` component follows the
[W3C breadcrumb accessibility design pattern](https://www.w3.org/TR/wai-aria-practices/#breadcrumb)
and applies the correct accessibility attributes to the `BreadcrumbView` listed below.
Implementations are expected to override `aria-label` with a translated value describing usage.

```jsx
const { Anchor } = require('@zendeskgarden/react-buttons/src');

<Breadcrumb aria-label="navegaciΓ³n">
<Anchor href="/">Home</Anchor>
<Anchor href="..">React Components</Anchor>
<Item>Breadcrumbs</Item>
</Breadcrumb>;
```
57 changes: 57 additions & 0 deletions packages/breadcrumbs/src/elements/Breadcrumb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright Zendesk, Inc.
*
* Use of this source code is governed under the Apache License, Version 2.0
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

import React, { Component, Children, cloneElement } from 'react';
import PropTypes from 'prop-types';
import { hasType } from '@zendeskgarden/react-utilities';

import BreadcrumbContainer from '../containers/BreadcrumbContainer';
import BreadcrumbView from '../views/BreadcrumbView';
import List from '../views/List';
import Item from '../views/Item';

/**
* High-level abstraction for basic Breadcrumb implementations. Accepts all
* `<ol>` props.
*/
export default class Breadcrumb extends Component {
static propTypes = {
children: PropTypes.any
};

renderItems = items => {
const total = Children.count(items);

return Children.map(items, (item, index) => {
const itemProps = {
current: index === total - 1,
key: index
};

return hasType(item, Item) ? (
cloneElement(item, itemProps)
) : (
<Item {...itemProps}>{item}</Item>
);
});
};

render() {
const { children, ...breadcrumbProps } = this.props;

return (
<BreadcrumbContainer>
{({ getContainerProps }) => (
/* role not needed as `BreadcrumbView` is a navigation landmark. */
<BreadcrumbView {...getContainerProps({ role: null })}>
<List {...breadcrumbProps}>{this.renderItems(children)}</List>
</BreadcrumbView>
)}
</BreadcrumbContainer>
);
}
}
Loading