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

feat(SkeletonIcon): add SkeletonIcon component #10838

Merged
merged 5 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions packages/carbon-react/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ describe('Carbon Components React', () => {
"SideNavMenu",
"SideNavMenuItem",
"SideNavSwitcher",
"SkeletonIcon",
"SkeletonPlaceholder",
"SkeletonText",
"SkipToContent",
Expand Down
1 change: 1 addition & 0 deletions packages/carbon-react/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export {
ToolbarDivider,
ToolbarSearch,
UnorderedList,
SkeletonIcon,
SkeletonText,
SkeletonPlaceholder,
DataTableSkeleton,
Expand Down
10 changes: 10 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5921,6 +5921,16 @@ Map {
},
"render": [Function],
},
"SkeletonIcon" => Object {
"propTypes": Object {
"className": Object {
"type": "string",
},
"style": Object {
"type": "object",
},
},
},
"SkeletonPlaceholder" => Object {
"propTypes": Object {
"className": Object {
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ describe('Carbon Components React', () => {
"SideNavMenu",
"SideNavMenuItem",
"SideNavSwitcher",
"SkeletonIcon",
"SkeletonPlaceholder",
"SkeletonText",
"SkipToContent",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import SkeletonIcon from '../SkeletonIcon';

const propsSkeleton = {
style: {
margin: '50px',
},
};

const propsSkeleton2 = {
style: {
margin: '50px',
width: '24px',
height: '24px',
},
};

export default {
title: 'Components/Skeleton/SkeletonIcon',
component: SkeletonIcon,
};

export const Default = () => (
<>
<SkeletonIcon {...propsSkeleton} />
<SkeletonIcon {...propsSkeleton2} />
</>
);
21 changes: 21 additions & 0 deletions packages/react/src/components/SkeletonIcon/SkeletonIcon-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import SkeletonIcon from '../SkeletonIcon';
import { shallow } from 'enzyme';
import { settings } from 'carbon-components';

const { prefix } = settings;

describe('SkeletonIcon', () => {
const wrapper = shallow(<SkeletonIcon />);

it('Has the expected classes', () => {
expect(wrapper.hasClass(`${prefix}--icon--skeleton`)).toEqual(true);
});
});
36 changes: 36 additions & 0 deletions packages/react/src/components/SkeletonIcon/SkeletonIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { usePrefix } from '../../internal/usePrefix';

const SkeletonIcon = ({ className, ...other }) => {
const prefix = usePrefix();

const skeletonIconClasses = classNames({
[`${prefix}--icon--skeleton`]: true,
[className]: className,
});

return <div className={skeletonIconClasses} {...other} />;
};

SkeletonIcon.propTypes = {
/**
* Specify an optional className to add.
*/
className: PropTypes.string,

/**
* The CSS styles.
*/
style: PropTypes.object,
};

export default SkeletonIcon;
8 changes: 8 additions & 0 deletions packages/react/src/components/SkeletonIcon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

export default from './SkeletonIcon';
1 change: 1 addition & 0 deletions packages/react/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export TooltipIcon from './components/TooltipIcon';
export UnorderedList from './components/UnorderedList';
export SkeletonText from './components/SkeletonText';
export SkeletonPlaceholder from './components/SkeletonPlaceholder';
export SkeletonIcon from './components/SkeletonIcon';
export DataTableSkeleton from './components/DataTableSkeleton';
export AccordionSkeleton from './components/Accordion/Accordion.Skeleton';
export BreadcrumbSkeleton from './components/Breadcrumb/Breadcrumb.Skeleton';
Expand Down