Skip to content

Commit

Permalink
feat(Carbon-React): add Loading -> UnorderedList (#9689)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
dakahn and kodiakhq[bot] committed Sep 21, 2021
1 parent d460ea0 commit 58b5202
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 59 deletions.
4 changes: 2 additions & 2 deletions packages/react/src/components/Loading/Loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/

import { settings } from 'carbon-components';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React, { useRef } from 'react';
import setupGetInstanceId from '../../tools/setupGetInstanceId';
import { usePrefix } from '../../internal/usePrefix';

const { prefix } = settings;
const getInstanceId = setupGetInstanceId();

function Loading({
Expand All @@ -23,6 +22,7 @@ function Loading({
description,
...rest
}) {
const prefix = usePrefix();
const { current: instanceId } = useRef(getInstanceId());
const loadingClassName = cx(customClassName, {
[`${prefix}--loading`]: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/MultiSelect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { WarningFilled16, WarningAltFilled16 } from '@carbon/icons-react';
import { settings } from 'carbon-components';
import cx from 'classnames';
import Downshift, { useSelect } from 'downshift';
import isEqual from 'lodash.isequal';
Expand All @@ -22,8 +21,8 @@ import { mapDownshiftProps } from '../../tools/createPropAdapter';
import mergeRefs from '../../tools/mergeRefs';
import { keys, match } from '../../internal/keyboard';
import { useFeatureFlag } from '../FeatureFlags';
import { usePrefix } from '../../internal/usePrefix';

const { prefix } = settings;
const noop = () => {};
const getInstanceId = setupGetInstanceId();
const {
Expand Down Expand Up @@ -71,6 +70,7 @@ const MultiSelect = React.forwardRef(function MultiSelect(
},
ref
) {
const prefix = usePrefix();
const { current: multiSelectInstanceId } = useRef(getInstanceId());
const [highlightedIndex, setHighlightedIndex] = useState(null);
const [isOpen, setIsOpen] = useState(open);
Expand Down
11 changes: 7 additions & 4 deletions packages/react/src/components/Notification/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import PropTypes from 'prop-types';
import React, { useEffect, useRef, useState } from 'react';
import cx from 'classnames';
import { settings } from 'carbon-components';
import {
Close20,
ErrorFilled20,
Expand All @@ -18,17 +17,16 @@ import {
InformationFilled20,
InformationSquareFilled20,
} from '@carbon/icons-react';

import Button from '../Button';

const { prefix } = settings;
import { usePrefix } from '../../internal/usePrefix';

export function NotificationActionButton({
children,
className: customClassName,
onClick,
...rest
}) {
const prefix = usePrefix();
const className = cx(
customClassName,
`${prefix}--inline-notification__action-button`
Expand Down Expand Up @@ -73,6 +71,7 @@ export function NotificationButton({
notificationType,
...rest
}) {
const prefix = usePrefix();
const buttonClassName = cx(className, {
[`${prefix}--${notificationType}-notification__close-button`]: notificationType,
});
Expand Down Expand Up @@ -150,6 +149,7 @@ export function NotificationTextDetails({
children,
...rest
}) {
const prefix = usePrefix();
if (notificationType === 'toast') {
return (
<div {...rest} className={`${prefix}--toast-notification__details`}>
Expand Down Expand Up @@ -218,6 +218,7 @@ const iconTypes = {
};

function NotificationIcon({ iconDescription, kind, notificationType }) {
const prefix = usePrefix();
const IconForKind = iconTypes[kind];
if (!IconForKind) {
return null;
Expand Down Expand Up @@ -261,6 +262,7 @@ export function ToastNotification({
timeout,
...rest
}) {
const prefix = usePrefix();
const [isOpen, setIsOpen] = useState(true);
const containerClassName = cx(className, {
[`${prefix}--toast-notification`]: true,
Expand Down Expand Up @@ -444,6 +446,7 @@ export function InlineNotification({
children,
...rest
}) {
const prefix = usePrefix();
const [isOpen, setIsOpen] = useState(true);
const containerClassName = cx(className, {
[`${prefix}--inline-notification`]: true,
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/components/OrderedList/OrderedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';
import { settings } from 'carbon-components';

const { prefix } = settings;
import { usePrefix } from '../../internal/usePrefix';

const OrderedList = ({
children,
Expand All @@ -20,6 +18,7 @@ const OrderedList = ({
isExpressive,
...other
}) => {
const prefix = usePrefix();
const classNames = classnames(
{
[`${prefix}--list--ordered`]: !native,
Expand Down
23 changes: 13 additions & 10 deletions packages/react/src/components/Select/Select.Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
import PropTypes from 'prop-types';
import React from 'react';
import cx from 'classnames';
import { settings } from 'carbon-components';
import { usePrefix } from '../../internal/usePrefix';

const { prefix } = settings;

const SelectSkeleton = ({ hideLabel, className, ...rest }) => (
<div className={cx(`${prefix}--form-item`, className)} {...rest}>
{!hideLabel && <span className={`${prefix}--label ${prefix}--skeleton`} />}
<div className={`${prefix}--select ${prefix}--skeleton`}>
<div className={`${prefix}--select-input`} />
const SelectSkeleton = ({ hideLabel, className, ...rest }) => {
const prefix = usePrefix();
return (
<div className={cx(`${prefix}--form-item`, className)} {...rest}>
{!hideLabel && (
<span className={`${prefix}--label ${prefix}--skeleton`} />
)}
<div className={`${prefix}--select ${prefix}--skeleton`}>
<div className={`${prefix}--select-input`} />
</div>
</div>
</div>
);
);
};

SelectSkeleton.propTypes = {
/**
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/components/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { settings } from 'carbon-components';
import {
ChevronDown16,
WarningFilled16,
WarningAltFilled16,
} from '@carbon/icons-react';
import deprecate from '../../prop-types/deprecate';
import { useFeatureFlag } from '../FeatureFlags';

const { prefix } = settings;
import { usePrefix } from '../../internal/usePrefix';

const Select = React.forwardRef(function Select(
{
Expand All @@ -43,6 +41,7 @@ const Select = React.forwardRef(function Select(
},
ref
) {
const prefix = usePrefix();
const enabled = useFeatureFlag('enable-v11-release');

const selectClasses = classNames(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { settings } from 'carbon-components';

const { prefix } = settings;
import { usePrefix } from '../../internal/usePrefix';

const SkeletonPlaceholder = ({ className, ...other }) => {
const prefix = usePrefix();
const skeletonPlaceholderClasses = classNames({
[`${prefix}--skeleton__placeholder`]: true,
[className]: className,
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/components/SkeletonText/SkeletonText.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { settings } from 'carbon-components';

const { prefix } = settings;
import { usePrefix } from '../../internal/usePrefix';

const randoms = [0.973051493507435, 0.15334737213558558, 0.5671034553053769];

Expand All @@ -26,6 +24,7 @@ const SkeletonText = ({
className,
...other
}) => {
const prefix = usePrefix();
const skeletonTextClasses = classNames({
[`${prefix}--skeleton__text`]: true,
[`${prefix}--skeleton__heading`]: heading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import PropTypes from 'prop-types';
import React from 'react';
import cx from 'classnames';
import { settings } from 'carbon-components';

const { prefix } = settings;
import { usePrefix } from '../../internal/usePrefix';

const StructuredListSkeleton = ({ rowCount, border, className, ...rest }) => {
const prefix = usePrefix();
const StructuredListSkeletonClasses = cx(className, {
[`${prefix}--skeleton`]: true,
[`${prefix}--structured-list`]: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { settings } from 'carbon-components';
import setupGetInstanceId from '../../tools/setupGetInstanceId';
import deprecate from '../../prop-types/deprecate';
import { usePrefix } from '../../internal/usePrefix';

const { prefix } = settings;
const getInstanceId = setupGetInstanceId();

export function StructuredListWrapper(props) {
Expand All @@ -26,6 +25,7 @@ export function StructuredListWrapper(props) {
border: _border,
...other
} = props;
const prefix = usePrefix();
const classes = classNames(`${prefix}--structured-list`, className, {
[`${prefix}--structured-list--selection`]: selection,
[`${prefix}--structured-list--condensed`]: isCondensed,
Expand Down Expand Up @@ -88,6 +88,7 @@ StructuredListWrapper.defaultProps = {

export function StructuredListHead(props) {
const { children, className, ...other } = props;
const prefix = usePrefix();
const classes = classNames(`${prefix}--structured-list-thead`, className);

return (
Expand All @@ -111,6 +112,7 @@ StructuredListHead.propTypes = {

export function StructuredListBody(props) {
const { children, className, ...other } = props;
const prefix = usePrefix();
const classes = classNames(`${prefix}--structured-list-tbody`, className);

return (
Expand Down Expand Up @@ -153,6 +155,7 @@ export function StructuredListRow(props) {
label,
...other
} = props;
const prefix = usePrefix();
const classes = classNames(`${prefix}--structured-list-row`, className, {
[`${prefix}--structured-list-row--header-row`]: head,
});
Expand Down Expand Up @@ -215,6 +218,7 @@ StructuredListRow.defaultProps = {

export function StructuredListInput(props) {
const { className, value, name, title, id, ...other } = props;
const prefix = usePrefix();
const classes = classNames(`${prefix}--structured-list-input`, className);
const instanceId = id || getInstanceId();

Expand Down Expand Up @@ -277,6 +281,7 @@ StructuredListInput.defaultProps = {

export function StructuredListCell(props) {
const { children, className, head, noWrap, ...other } = props;
const prefix = usePrefix();
const classes = classNames(className, {
[`${prefix}--structured-list-th`]: head,
[`${prefix}--structured-list-td`]: !head,
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/components/Tag/Tag.Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import PropTypes from 'prop-types';
import React from 'react';
import cx from 'classnames';
import { settings } from 'carbon-components';

const { prefix } = settings;
import { usePrefix } from '../../internal/usePrefix';

function TagSkeleton({ className, size, ...rest }) {
const prefix = usePrefix();
return (
<span
className={cx(`${prefix}--tag`, `${prefix}--skeleton`, className, {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Tag/Tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { settings } from 'carbon-components';
import { Close16 } from '@carbon/icons-react';
import setupGetInstanceId from '../../tools/setupGetInstanceId';
import { usePrefix } from '../../internal/usePrefix';

const { prefix } = settings;
const getInstanceId = setupGetInstanceId();
const TYPES = {
red: 'Red',
Expand Down Expand Up @@ -41,6 +40,7 @@ const Tag = ({
size,
...other
}) => {
const prefix = usePrefix();
const tagId = id || `tag-${getInstanceId()}`;
const tagClasses = classNames(`${prefix}--tag`, className, {
[`${prefix}--tag--disabled`]: disabled,
Expand Down
21 changes: 12 additions & 9 deletions packages/react/src/components/TextArea/TextArea.Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
import PropTypes from 'prop-types';
import React from 'react';
import cx from 'classnames';
import { settings } from 'carbon-components';
import { usePrefix } from '../../internal/usePrefix';

const { prefix } = settings;

const TextAreaSkeleton = ({ hideLabel, className, ...rest }) => (
<div className={cx(`${prefix}--form-item`, className)} {...rest}>
{!hideLabel && <span className={`${prefix}--label ${prefix}--skeleton`} />}
<div className={`${prefix}--skeleton ${prefix}--text-area`} />
</div>
);
const TextAreaSkeleton = ({ hideLabel, className, ...rest }) => {
const prefix = usePrefix();
return (
<div className={cx(`${prefix}--form-item`, className)} {...rest}>
{!hideLabel && (
<span className={`${prefix}--label ${prefix}--skeleton`} />
)}
<div className={`${prefix}--skeleton ${prefix}--text-area`} />
</div>
);
};

TextAreaSkeleton.propTypes = {
/**
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/components/TextArea/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { settings } from 'carbon-components';
import { WarningFilled16 } from '@carbon/icons-react';
import { useFeatureFlag } from '../FeatureFlags';

const { prefix } = settings;
import { usePrefix } from '../../internal/usePrefix';

const TextArea = React.forwardRef(function TextArea(
{
Expand All @@ -31,6 +29,7 @@ const TextArea = React.forwardRef(function TextArea(
},
ref
) {
const prefix = usePrefix();
const enabled = useFeatureFlag('enable-v11-release');

const textareaProps = {
Expand Down
Loading

0 comments on commit 58b5202

Please sign in to comment.