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

V9 changes to master #825

Merged
merged 47 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
452a195
feat(inputs): fixed old pr and added inputs and colors work (#756)
marijohannessen May 9, 2018
e1a8ba8
chore(devenv): introduced parameterized demo HTML (#579)
asudoh May 15, 2018
ae7ba9a
feat(code-snippet): Add new Code snippet variation and styles (#761)
alisonjoseph May 16, 2018
dad879b
V9 merge 05162018 (#773)
asudoh May 17, 2018
7032581
fix(code-snippet): Update templates (#779)
alisonjoseph May 17, 2018
8788c1b
fix(pagination): bring v2 version back (#782)
asudoh May 18, 2018
f16bc90
chore(devenv): fix full-render demo (#783)
asudoh May 18, 2018
01dbb91
V9 merge 05182018 (#785)
asudoh May 18, 2018
69175d3
chore(devenv): update variant labels (#784)
asudoh May 18, 2018
e4a4f7d
feat(tooltip): add definition tooltip (#714)
aledavila May 22, 2018
93d4f45
chore(files): remove yarn-error.log (#800)
asudoh May 23, 2018
6ae643a
chore(package): remove npm5 lockfile and add lockfile to gitignore (#…
joshblack May 23, 2018
8b71974
V9 merge 05212018 (#801)
asudoh May 24, 2018
f665166
chore(package): update lockfile to remove artifactory references (#808)
joshblack May 24, 2018
41cae7e
Light dropdown styles (#809)
alisonjoseph May 24, 2018
455544e
Icon updates (#810)
tw15egan May 25, 2018
5ce15ca
fix(components): some small fixes for v9 (#812)
marijohannessen May 29, 2018
dff4d3f
732 search (#811)
aledavila May 29, 2018
5cd0c48
fix(form): fixed button width (#819)
marijohannessen May 30, 2018
6d7c0c1
fix(docs): Update Component docs (#815)
alisonjoseph May 30, 2018
f33982b
fix(code-snippet): fixed a render issue for the light version (#817)
marijohannessen May 30, 2018
2f4ae3a
feat(slider): Light variation (#818)
alisonjoseph May 30, 2018
f33485b
feat(checkbox): Update checkboxes to match new icon set (#822)
alisonjoseph May 31, 2018
59b4598
fix: Add code snippet example skeleton state html (#827)
alisonjoseph May 31, 2018
b23bf4b
chore(tooltip): change to lowercase 'label' (#836)
aledavila May 31, 2018
6230fe3
fix(search): close button positioning for custom react search (#835)
aledavila May 31, 2018
fe52069
fix(radio): Update radio + checkbox border colors (#834)
tw15egan May 31, 2018
26f60cf
fix(icons): Update data table v2 & card icons (#826)
alisonjoseph May 31, 2018
5091f5d
fix(pagination): update colors (#832)
tw15egan May 31, 2018
38184e4
fix(multi-select): update hover color (#830)
tw15egan May 31, 2018
daafe4d
fix(v9): small fixes to components (#838)
tw15egan May 31, 2018
febe7de
fix(multi-select): fix HTML structure of multi select (#840)
asudoh Jun 1, 2018
2ede487
fix(pagination): fix text input position in pagination V1 (#841)
asudoh Jun 1, 2018
153510c
fix(tooltip): Definition tooltip positioning fix (#843)
alisonjoseph Jun 1, 2018
b09e158
fix(tooltip): update tooltip definition markup
alisonjoseph Jun 1, 2018
8784612
fix: Add back in js positioning
alisonjoseph Jun 1, 2018
823772e
chore: cleanup js comments
alisonjoseph Jun 1, 2018
d855cfe
fix(tooltips: Tooltip a11y (#846)
alisonjoseph Jun 1, 2018
8d01153
fix(tooltip): position fix (#848)
asudoh Jun 1, 2018
23539d8
fix(icons): update icons, other small fixes (#849)
tw15egan Jun 1, 2018
e5ee023
fix(code-snippet): fixed feedback not showing up in firefox (#852)
marijohannessen Jun 4, 2018
c6f5f14
chore: update dev env to work in IE11 (#853)
joshblack Jun 4, 2018
a981d74
chore: remove deprecated components (#855)
joshblack Jun 4, 2018
6c108cd
fix(components): misc fixes for v9 (#854)
marijohannessen Jun 4, 2018
dd247f0
fix(form): remove margins from bx--form-item (#861)
tw15egan Jun 4, 2018
251f11b
fix(list-box): removed styles on disabled item (#862)
marijohannessen Jun 4, 2018
9207da9
fix(select): position arrow based on bottom rather than top (#864)
tw15egan Jun 4, 2018
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
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ tests/coverage
/html
/docs/js
node_modules

# TODO: Upgrade to ESLint4 so we can apply a specific rule (one for CJS code) for below files
src/**/*.config.js
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ tests/coverage

# a11y testing
.aat.yml

# Generated by npm@5, but project currently uses Yarn
package-lock.json
2 changes: 1 addition & 1 deletion demo/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
],
"react"
],
"plugins": ["transform-class-properties", "dev-expression"]
"plugins": ["transform-class-properties", "transform-object-rest-spread", "dev-expression"]
}
34 changes: 5 additions & 29 deletions demo/js/components/CodePage/CodePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,36 @@ import Markdown from 'markdown-it';

import ComponentExample from '../ComponentExample/ComponentExample';

/**
* @param {ComponentCollection|Component} metadata The component data.
* @returns {string} The HTML snippet for the component.
*/
const getContent = metadata => {
const { variants = {} } = metadata;
const { items = [] } = variants;
const variant = items[0];
return metadata.content || (variant && variant.content) || '';
};

/**
* @param {ComponentCollection|Component} metadata The component data.
* @returns {Component[]|Variant[]} The data of the component variants.
*/
const getSubItems = metadata => {
if (metadata.isCollection) {
return metadata.items;
}
if (!metadata.isCollated) {
return metadata.variants.items;
}
return [];
};

/**
* The page to show the component demo, its code as well as its README.
*/
const CodePage = ({ metadata, hideViewFullRender }) => {
const md = new Markdown({ html: true });
const subItems = getSubItems(metadata).filter(item => !item.isHidden);
const subItems = (metadata.items || []).filter(item => !item.isHidden);
/* eslint-disable react/no-danger */
const componentContent =
!metadata.isCollection && subItems.length <= 1 ? (
<ComponentExample
hideViewFullRender={hideViewFullRender}
component={metadata.name}
htmlFile={getContent(metadata)}
htmlFile={metadata.renderedContent}
useIframe={metadata.useIframe}
/>
) : (
subItems.map(item => (
<div key={item.id} className="component-variation">
<h2 className="component-variation__name">{item.label}</h2>
{item.notes && metadata.notes !== item.notes && <p>{item.notes}</p>}
<ComponentExample
variant={item.handle.replace(/--default$/, '')}
component={metadata.name}
htmlFile={getContent(item)}
htmlFile={item.renderedContent}
useIframe={metadata.useIframe}
/>
</div>
))
);

/* eslint-disable react/no-danger */
return (
<div className="page code-page test">
{componentContent}
Expand Down
3 changes: 2 additions & 1 deletion demo/js/components/ComponentExample/ComponentExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class ComponentExample extends Component {
});

const codepenLink = codepenSlug && `https://codepen.io/team/carbon/full/${codepenSlug}/`;
const componentLink = variant ? `/component/${component}/${variant}` : `/component/${component}`;
const variantSuffix = (component === variant && '--default') || '';
const componentLink = variant ? `/component/${variant}${variantSuffix}` : `/component/${component}`;

const viewFullRender = hideViewFullRender ? null : (
<Link className="component-example__view-full-render" target="_blank" href={codepenLink || componentLink}>
Expand Down
95 changes: 89 additions & 6 deletions demo/js/components/RootPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,67 @@ import SideNav from './SideNav';
import PageHeader from './PageHeader/PageHeader';
import SideNavToggle from './SideNavToggle/SideNavToggle';

const checkStatus = response => {
if (response.status >= 200 && response.status < 400) {
return response;
}

const error = new Error(response.statusText);
error.response = response;
throw error;
};

const load = (componentItems, selectedNavItemId) => {
const metadata = componentItems && componentItems.find(item => item.id === selectedNavItemId);
const subItems = metadata.items || [];
const hasRenderedContent =
!metadata.isCollection && subItems.length <= 1 ? metadata.renderedContent : subItems.every(item => item.renderedContent);
if (!hasRenderedContent) {
return fetch(`/code/${metadata.name}`)
.then(checkStatus)
.then(response => {
const contentType = response.headers.get('content-type');
return contentType && contentType.includes('application/json') ? response.json() : response.text();
})
.then(responseContent => {
if (Object(responseContent) === responseContent) {
return componentItems.map(item => {
if (item.id !== selectedNavItemId) {
return item;
}
return !item.items
? {
...item,
renderedContent: responseContent[`${item.handle}--default`],
}
: {
...item,
items: item.items.map(
subItem =>
!responseContent[subItem.handle]
? subItem
: {
...subItem,
renderedContent: responseContent[subItem.handle],
}
),
};
});
}
return componentItems.map(
item =>
item.id !== selectedNavItemId
? item
: {
...item,
renderedContent: responseContent,
}
);
});
}
return Promise.resolve(null);
};

/**
* The top-most React component for dev env page.
*/
Expand All @@ -22,9 +83,19 @@ class RootPage extends Component {
docItems: PropTypes.arrayOf(PropTypes.shape()).isRequired, // eslint-disable-line react/no-unused-prop-types
};

constructor() {
constructor(props) {
super();
this.state = {};

const { componentItems } = props;

this.state = {
/**
* The array of component data.
* @type {Object[]}
*/
componentItems,
};

window.addEventListener('popstate', evt => {
this.switchTo(evt.state.name);
});
Expand All @@ -42,6 +113,13 @@ class RootPage extends Component {
}
}

componentWillReceiveProps(props) {
const { componentItems } = props;
if (this.props.componentItems !== componentItems) {
this.setState({ componentItems });
}
}

/**
* The handler for changing in the state of side nav's toggle button.
*/
Expand All @@ -53,7 +131,7 @@ class RootPage extends Component {
* The handler for the `click` event on the side nav for changing selection.
*/
onSideNavItemClick = evt => {
const { componentItems } = this.props;
const { componentItems } = this.state;
const selectedNavItem = componentItems && componentItems.find(item => item.id === evt.target.dataset.navId);
if (selectedNavItem) {
this.switchTo(selectedNavItem.id);
Expand All @@ -64,7 +142,7 @@ class RootPage extends Component {
* @returns The component data that is currently selected.
*/
getCurrentComponentItem() {
const { componentItems } = this.props;
const { componentItems } = this.state;
return componentItems && componentItems.find(item => item.id === this.state.selectedNavItemId);
}

Expand All @@ -74,17 +152,22 @@ class RootPage extends Component {
*/
switchTo(selectedNavItemId) {
this.setState({ selectedNavItemId }, () => {
const { componentItems } = this.props;
const { componentItems } = this.state;
const selectedNavItem = componentItems && componentItems.find(item => item.id === selectedNavItemId);
const { name } = selectedNavItem || {};
if (name) {
history.pushState({ name }, name, `/demo/${name}`);
}
load(componentItems, selectedNavItemId).then(newComponentItems => {
if (newComponentItems) {
this.setState({ componentItems: newComponentItems });
}
});
});
}

render() {
const { componentItems } = this.props;
const { componentItems } = this.state;
const metadata = this.getCurrentComponentItem();
const { name, label } = metadata || {};
const classNames = classnames({
Expand Down
14 changes: 12 additions & 2 deletions demo/polyfills/devenv.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
// Polyfill for dev env UI based on `carbon-components-react`
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-extraneous-dependencies, global-require */
import 'core-js/modules/es6.string.includes';
import 'core-js/modules/es7.object.values';
/* eslint-enable import/no-extraneous-dependencies */
import 'whatwg-fetch';

if (typeof Promise === 'undefined') {
// Rejection tracking prevents a common issue where React gets into an
// inconsistent state due to an error, but it gets swallowed by a Promise,
// and the user has no idea what causes React's erratic future behavior.
require('promise/lib/rejection-tracking').enable();
window.Promise = require('promise/lib/es6-extensions.js');
}
/* eslint-enable import/no-extraneous-dependencies, global-require */
10 changes: 5 additions & 5 deletions demo/scss/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ td {
}
}

button {
border-radius: 0;
}

& > *:not(.component-example):not(.component-variation),
& > {
& > {
button {
border-radius: 0;
}

.page__divider-heading {
@include typescale('zeta');
font-weight: 600;
Expand Down
44 changes: 0 additions & 44 deletions demo/views/demo-live.dust

This file was deleted.

15 changes: 15 additions & 0 deletions demo/views/demo-nav-data.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
var needIframe = [
'detail-page-header',
'footer',
'grid',
'unified-header',
];
var componentItems = {{{JSONstringify componentItems}}}.map(function (item) {
if (needIframe.indexOf(item.name) >= 0) {
item.useIframe = true;
}
return item;
});
var docItems = {{{JSONstringify docItems}}};
</script>
16 changes: 1 addition & 15 deletions demo/views/demo-nav.dust → demo/views/layouts/demo-nav.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,7 @@
<body>
<div data-renderroot></div>
<input aria-label="inpute-text-offleft" type="text" class="offleft" />
<script>
var needIframe = [
'detail-page-header',
'footer',
'grid',
'unified-header',
];
var componentItems = {componentItems|js|s}.map(function (item) {
if (needIframe.indexOf(item.name) >= 0) {
item.useIframe = true;
}
return item;
});
var docItems = {docItems|js|s};
</script>
{{{body}}}
<script src="/demo/demo.js"></script>
</body>
</html>
Loading