Skip to content

Commit

Permalink
chore(props): fix props and attribute errors (#5041)
Browse files Browse the repository at this point in the history
### Description

Fixes various props/attribute validation errors

### Changelog

**Changed**

- various prop type and attribute naming errors

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "package: styles": Carbon Expressive -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
kennylam authored Feb 1, 2021
1 parent 34a096d commit 8575a21
Show file tree
Hide file tree
Showing 17 changed files with 522 additions and 119 deletions.
498 changes: 449 additions & 49 deletions packages/react/src/__tests__/__snapshots__/storyshots.test.js.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -10,7 +10,7 @@ import CTASection from '../CTASection';
import React from 'react';
import readme from '../README.stories.mdx';

const types = ['local', 'external', 'default'];
const types = ['local', 'external'];

const contentItemsProps = [
{
Expand Down Expand Up @@ -78,12 +78,12 @@ Default.story = {
type: types[0],
buttons: [
{
type: select('ContentBlock | CTA type', types, types[2], groupId),
type: select('ContentBlock | CTA type', types, types[0], groupId),
copy: 'Secondary button',
href: 'https://example.com/',
},
{
type: select('ContentBlock | CTA type', types, types[2], groupId),
type: select('ContentBlock | CTA type', types, types[0], groupId),
copy: 'Primary button',
href: 'https://example.com/',
},
Expand Down Expand Up @@ -137,12 +137,12 @@ WithContentItems.story = {
type: types[0],
buttons: [
{
type: select('CTA (type):', types, types[2], groupId),
type: select('CTA (type):', types, types[0], groupId),
copy: 'Secondary button',
href: 'https://example.com/',
},
{
type: select('CTA (type):', types, types[2], groupId),
type: select('CTA (type):', types, types[0], groupId),
copy: 'Primary button',
href: 'https://example.com/',
},
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/CalloutData/CalloutData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -35,7 +35,7 @@ const CalloutData = ({ data, copy, source }) =>
</div>
);

CalloutData.PropTypes = {
CalloutData.propTypes = {
/**
* Data for CalloutData pattern.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Default = () => {
This component is maintined in{' '}
<code>@carbon/ibmdotcom-web-components</code> library with a{' '}
<a
class="bx--link"
className="bx--link"
target="_blank"
href="http://ibmdotcom-web-components-react.mybluemix.net/?path=/story/components-card-section-carousel--default">
React wrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default {

export const Default = ({ parameters }) => {
const { heading, cards } = parameters?.props?.CardSectionSimple ?? {};
const theme = document.documentElement.getAttribute('storybook-carbon-theme');
const theme =
document.documentElement.getAttribute('storybook-carbon-theme') || 'white';
return <CardSectionSimple heading={heading} theme={theme} cards={cards} />;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -26,7 +26,7 @@ export const Default = () => {
This component is maintined in{' '}
<code>@carbon/ibmdotcom-web-components</code> library with a{' '}
<a
class="bx--link"
className="bx--link"
target="_blank"
href="https://ibmdotcom-web-components-react.mybluemix.net/?path=/story/components-carousel--default">
React wrapper
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/DotcomShell/DotcomShell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -69,7 +69,7 @@ DotcomShell.propTypes = {
})
),
}),
type: PropTypes.oneOf(['tall', 'short']),
type: PropTypes.oneOf(['tall', 'short', 'micro']),
langCode: PropTypes.shape({
cc: PropTypes.string,
lc: PropTypes.string,
Expand Down
9 changes: 6 additions & 3 deletions packages/react/src/components/Footer/LanguageSelector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -91,6 +91,7 @@ const LanguageSelector = ({
<Select
defaultValue={selectedItem.id}
data-autoid={`${stablePrefix}--language-selector__select`}
id={`${prefix}--language-selector`}
className={`${prefix}--language-selector`}
onChange={evt => _setSelectedItem(evt)}
text={selectedItem.text}
Expand All @@ -110,8 +111,10 @@ const LanguageSelector = ({

function renderSelectItems(items) {
const selectItems = [];
items.map(item => {
selectItems.push(<SelectItem value={item.id} text={item.text} />);
items.map((item, index) => {
selectItems.push(
<SelectItem value={item.id} text={item.text} key={index} />
);
});
return selectItems;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Footer/LegalNav.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -81,7 +81,7 @@ LegalNav.propTypes = {
* The locale/language selector button.
* Renders only in micro version
*/
button: PropTypes.func,
button: PropTypes.object,
};

LegalNav.defaultProps = {
Expand Down
29 changes: 13 additions & 16 deletions packages/react/src/components/LeadSpace/LeadSpace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -68,7 +68,6 @@ const LeadSpace = ({ buttons, copy, gradient, image, theme, title, type }) => {
const background = image && {
backgroundImage: `url(${image.defaultSrc})`,
};

return (
<div
data-autoid={`${stablePrefix}--leadspace`}
Expand Down Expand Up @@ -133,20 +132,18 @@ LeadSpace.propTypes = {
* Object with different ratio options for corresponding breakpoints.
* See [`<Image>`'s README](http://ibmdotcom-react.mybluemix.net/?path=/docs/components-image--default#props) for full usage details.
*/
image: PropTypes.shape(
PropTypes.shape({
classname: PropTypes.string,
sources: PropTypes.arrayOf(
PropTypes.shape({
src: PropTypes.string,
breakpoint: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
})
),
defaultSrc: PropTypes.string.isRequired,
alt: PropTypes.string.isRequired,
longDescription: PropTypes.string,
})
),
image: PropTypes.shape({
classname: PropTypes.string,
sources: PropTypes.arrayOf(
PropTypes.shape({
src: PropTypes.string,
breakpoint: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
})
),
defaultSrc: PropTypes.string.isRequired,
alt: PropTypes.string.isRequired,
longDescription: PropTypes.string,
}),

/**
* Color theme of LeadSpace. Choose from:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -19,25 +19,27 @@ const LeadspaceWithSearch = ({ heading, copy, searchProps }) => {
const leadspaceContainer = useRef(null);

useEffect(() => {
if (leadspaceContainer) {
const { current } = leadspaceContainer;
const observer = new ResizeObserver(entries => {
for (const entry of entries) {
const CARBON_MD_BREAKPOINT = 672;
const { inlineSize: leadspaceWidth } = entry.borderBoxSize[0];
const { desktop, mobile } = searchProps.placeHolder;
leadspaceContainer.current = new ResizeObserver(entries => {
for (const entry of entries) {
const CARBON_MD_BREAKPOINT = 672;
const { inlineSize: leadspaceWidth } = entry.borderBoxSize[0];
const { desktop, mobile } = searchProps.placeholder;

if (leadspaceWidth > CARBON_MD_BREAKPOINT || !mobile) {
setSearchplaceHolder(desktop);
}
if (leadspaceWidth <= CARBON_MD_BREAKPOINT && mobile) {
setSearchplaceHolder(mobile);
}
if (leadspaceWidth > CARBON_MD_BREAKPOINT || !mobile) {
setSearchplaceHolder(desktop);
}
});
observer?.observe(current);
}
}, [searchProps.placeHolder]);
if (leadspaceWidth <= CARBON_MD_BREAKPOINT && mobile) {
setSearchplaceHolder(mobile);
}
}
});
leadspaceContainer.current.observe(document.documentElement);

return () => {
leadspaceContainer.current.disconnect();
leadspaceContainer.current = null;
};
}, [searchProps.placeholder]);

return heading ? (
<section
Expand Down Expand Up @@ -84,17 +86,17 @@ LeadspaceWithSearch.propTypes = {
* Any other functions and properties passed down to this will be applyed to the [Search component](https://www.carbondesignsystem.com/components/search/usage/).
*
*/
searchProps: {
searchProps: PropTypes.shape({
/**
* The Leadspace With Search accepts two placeholders. One for mobile view and another for desktop. Both are optional. If you do not provide, it will be set to "Search".
*/
placeHolder: PropTypes.shape({
placeholder: PropTypes.shape({
mobile: PropTypes.string,
desktop: PropTypes.string,
}),
labelText: PropTypes.string,
...Search.propTypes,
},
}),
};

LeadspaceWithSearch.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -26,7 +26,7 @@ export default !DDS_LEADSPACE_WITH_SEARCH
groupId
),
searchProps: {
placeHolder: {
placeholder: {
mobile: text(
'Mobile placeholder (searchProps.placeHolder.mobile):',
'Search keywords',
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/components/LinkList/LinkList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -40,7 +40,7 @@ const LinkList = ({ heading, iconPlacement, items, style }) => {
<CTA
style={linkStyle}
{...cta}
disableImage={true}
disableImage
{...(iconPlacement &&
linkStyle === 'text' && { iconPlacement })}
/>
Expand All @@ -56,7 +56,7 @@ LinkList.propTypes = {
/**
* Describes heading of LinkList.
*/
heading: PropTypes.string.isRequired,
heading: PropTypes.string,

/**
* Describes the list of CTA.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -35,7 +35,7 @@ const MegaMenu = ({ data, ...rest }) => {
{highlightedItems.map((item, i) => (
<CategoryGroup
autoid={rest.autoid}
index={i}
key={i}
href={item.url}
title={item.title}>
{item.megapanelContent?.quickLinks?.links.map(
Expand All @@ -44,7 +44,7 @@ const MegaMenu = ({ data, ...rest }) => {
href={url}
title={title}
autoid={`${rest.autoid}-list${i}`}
index={key}
key={key}
/>
)
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* istanbul ignore file */

/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -289,7 +289,7 @@ class HeaderMenu extends React.Component {
*/
_renderMenuItem = (item, index) => {
return React.cloneElement(item, {
ref: this.handleItemRef(index),
refs: this.handleItemRef(index),
role: 'none',
});
};
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/internal/components/Callout/Callout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -36,7 +36,7 @@ Callout.propTypes = {
/**
* The component being imported into the callout container.
*/
children: PropTypes.object,
children: PropTypes.node,
};

export default Callout;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2020
* Copyright IBM Corp. 2016, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -42,7 +42,7 @@ ConditionalWrapper.propTypes = {
/**
* Wrapper element
*/
wrapper: PropTypes.node,
wrapper: PropTypes.func,

/**
* Children elements
Expand Down

0 comments on commit 8575a21

Please sign in to comment.