From 3930cbd1fbd80a7adf547a9a813e1e25fc8961a7 Mon Sep 17 00:00:00 2001 From: Balbina Kotula <41303231+BalbinaK@users.noreply.github.com> Date: Wed, 8 Jun 2022 13:28:12 +0200 Subject: [PATCH] Revert "Release from next to main (#120)" This reverts commit 289290ff44891cdaec7d75976da2ad9aa6295286. --- CHANGELOG.md | 36 ------- docs/src/Main.tsx | 5 - index.html | 5 +- package.json | 6 +- packages/_helpers/affix.tsx | 6 +- packages/_helpers/expand-transition.tsx | 53 ---------- packages/_helpers/index.ts | 1 - packages/alert/docs/Alert.mdx | 80 -------------- packages/alert/src/component.tsx | 123 ---------------------- packages/alert/src/index.ts | 2 - packages/alert/src/props.tsx | 16 --- packages/alert/stories/Alert.stories.tsx | 92 ---------------- packages/box/src/component.tsx | 2 +- packages/card/src/component.tsx | 2 +- packages/expandable/src/component.tsx | 45 ++++---- packages/index.ts | 1 - packages/modal/docs/Modal.mdx | 19 +--- packages/modal/src/component.tsx | 2 +- packages/steps/src/step.tsx | 2 +- packages/switch/src/component.tsx | 2 +- packages/tabs/src/component-tab-panel.tsx | 2 +- packages/tabs/src/component-tab.tsx | 2 +- packages/tabs/src/component-tabs.tsx | 2 +- 23 files changed, 38 insertions(+), 468 deletions(-) delete mode 100644 packages/_helpers/expand-transition.tsx delete mode 100644 packages/alert/docs/Alert.mdx delete mode 100644 packages/alert/src/component.tsx delete mode 100644 packages/alert/src/index.ts delete mode 100644 packages/alert/src/props.tsx delete mode 100644 packages/alert/stories/Alert.stories.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 35f8daca..ab310a8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,39 +1,3 @@ -# [1.2.0-next.5](https://github.com/fabric-ds/react/compare/v1.2.0-next.4...v1.2.0-next.5) (2022-06-08) - - -### Bug Fixes - -* bump component-classes to get Step fix ([c17ce7e](https://github.com/fabric-ds/react/commit/c17ce7e83e1e78aca28e867dbf29331d69c549fe)) - -# [1.2.0-next.4](https://github.com/fabric-ds/react/compare/v1.2.0-next.3...v1.2.0-next.4) (2022-06-08) - - -### Bug Fixes - -* **animated-expansion:** rename to ExpandTransition and check if element ref exists ([#119](https://github.com/fabric-ds/react/issues/119)) ([b7a8026](https://github.com/fabric-ds/react/commit/b7a8026dd17e6c53c1fe3b1831964b104bfc5087)) -* bump component-classes to get Step fix ([5d99506](https://github.com/fabric-ds/react/commit/5d99506bcf45f531522670e6a910f11e671c1a54)) - -# [1.2.0-next.3](https://github.com/fabric-ds/react/compare/v1.2.0-next.2...v1.2.0-next.3) (2022-06-07) - - -### Bug Fixes - -* **affix:** Add aria-label to Affix icons ([17fab00](https://github.com/fabric-ds/react/commit/17fab00e1f939531a613df6e2ba9e752e5e9d23e)) - -# [1.2.0-next.2](https://github.com/fabric-ds/react/compare/v1.2.0-next.1...v1.2.0-next.2) (2022-06-02) - - -### Features - -* **alert:** add expand and collapse behaviour to inline alert ([#114](https://github.com/fabric-ds/react/issues/114)) ([075f314](https://github.com/fabric-ds/react/commit/075f314adfa468960a42f7c87af855d2f1ddce6d)) - -# [1.2.0-next.1](https://github.com/fabric-ds/react/compare/v1.1.1...v1.2.0-next.1) (2022-05-31) - - -### Features - -* **packages:** add inline Alert component ([#106](https://github.com/fabric-ds/react/issues/106)) ([ddfe084](https://github.com/fabric-ds/react/commit/ddfe0842c2af00e3dc531fbff25d18f395a5dfe7)) - ## [1.1.1](https://github.com/fabric-ds/react/compare/v1.1.0...v1.1.1) (2022-05-23) diff --git a/docs/src/Main.tsx b/docs/src/Main.tsx index 1ef91e3d..ae6c49ac 100644 --- a/docs/src/Main.tsx +++ b/docs/src/Main.tsx @@ -6,7 +6,6 @@ import { Route, Switch as ReactSwitch, } from 'react-router-dom'; -import Alert from '../../packages/alert/docs/Alert.mdx'; import Box from '../../packages/box/docs/Box.mdx'; import Breadcrumbs from '../../packages/breadcrumbs/docs/Breadcrumbs.mdx'; import Button from '../../packages/button/docs/Button.mdx'; @@ -47,10 +46,6 @@ const App = () => { - - - - diff --git a/index.html b/index.html index d77c2a4e..da4a1a3b 100644 --- a/index.html +++ b/index.html @@ -55,10 +55,7 @@ { "title": "Feedback indicators", "open": true, - "items": [ - { "title": "Alert", "href": "/alert" }, - { "title": "Steps", "href": "/steps" } - ] + "items": [{ "title": "Steps", "href": "/steps" }] }, { "title": "Forms", diff --git a/package.json b/package.json index 00234fee..19aff0f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fabric-ds/react", - "version": "1.2.0-next.5", + "version": "1.1.1", "repository": "git@github.com:fabric-ds/react.git", "license": "ISC", "type": "module", @@ -48,7 +48,9 @@ "@babel/core": "^7.12.10", "@chbphone55/classnames": "^2.0.0", "@eik/esbuild-plugin": "^1.1.0", + "@fabric-ds/component-classes": "^0.0.38", "@fabric-ds/icons": "^0.3.12", + "@fabric-ds/tailwind-config": "^0.5.20", "@mdx-js/mdx": "^1.6.22", "@mdx-js/react": "1.6.22", "@semantic-release/changelog": "^6.0.1", @@ -103,7 +105,7 @@ "dependencies": { "@chbphone55/classnames": "^2.0.0", "@fabric-ds/core": "0.0.13", - "@fabric-ds/css": "^1.1.4", + "@fabric-ds/css": "^1.1.2", "d3-scale": "^4.0.2", "react-focus-lock": "^2.5.2", "react-spring": "^8.0.27", diff --git a/packages/_helpers/affix.tsx b/packages/_helpers/affix.tsx index e3f97625..f44bc1e4 100644 --- a/packages/_helpers/affix.tsx +++ b/packages/_helpers/affix.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { suffix, prefix } from '@fabric-ds/css/component-classes'; +import { suffix, prefix } from '@fabric-ds/component-classes'; import { classNames } from '@chbphone55/classnames'; interface AffixProps { @@ -43,8 +43,6 @@ export function Affix(props: AffixProps) { <> {props.clear && ( ) { - const [isExpanded, setIsExpanded] = useState(show); - const expandableRef = useRef(null); - const isMounted = useRef(false); - - async function collapseElement(el: HTMLElement) { - await new Promise((resolve) => { - collapse(el, resolve); - }); - setIsExpanded(false); - } - - function expandElement(el: HTMLElement) { - expand(el); - setIsExpanded(true); - } - - useEffect(() => { - // Don't do anything at first render - if (!isMounted.current) { - isMounted.current = true; - return; - } - - if (!expandableRef.current) return; - - if (show) { - expandElement(expandableRef.current); - } else { - collapseElement(expandableRef.current); - } - }, [show]); - - return ( -
- {children} -
- ); -} diff --git a/packages/_helpers/index.ts b/packages/_helpers/index.ts index 189dec17..eeb873a1 100644 --- a/packages/_helpers/index.ts +++ b/packages/_helpers/index.ts @@ -1,4 +1,3 @@ export { Clickable } from './clickable'; export { DeadToggle } from './dead-toggle'; export { Affix } from './affix'; -export { ExpandTransition } from './expand-transition'; diff --git a/packages/alert/docs/Alert.mdx b/packages/alert/docs/Alert.mdx deleted file mode 100644 index 82746838..00000000 --- a/packages/alert/docs/Alert.mdx +++ /dev/null @@ -1,80 +0,0 @@ -import { Alert } from '../src'; -import { Button } from '../../button/src'; - -# Alert - -Alert is an inline component used for displaying different types of messages. - -## Import - -```js -import { Alert } from '@fabric-ds/react'; -``` - -## Visual Options - -### Expandable behaviour - -```jsx example -function ExpandableAlert() { - const [show, setShow] = React.useState(true); - - return ( - <> - -

Title Caption-Strong

-

This is the message text that can be short or a little bit long

- Link to more information -
- - -
-
- - - - ); -} -``` - -### Negative - -```jsx example - - This is the message text that can be short or a little bit long - -``` - -### Positive - -```jsx example - - This is the message text that can be short or a little bit long - -``` - -### Warning - -```jsx example - - This is the message text that can be short or a little bit long - -``` - -### Info - -```jsx example - - This is the message text that can be short or a little bit long - -``` - -## Props - -```props packages/alert/src/component.tsx - -``` diff --git a/packages/alert/src/component.tsx b/packages/alert/src/component.tsx deleted file mode 100644 index 22977c12..00000000 --- a/packages/alert/src/component.tsx +++ /dev/null @@ -1,123 +0,0 @@ -import { classNames } from '@chbphone55/classnames'; -import React, { PropsWithChildren, ReactElement } from 'react'; -import { AlertProps } from '.'; -import { ExpandTransition } from '../../_helpers'; - -export function Alert({ - show, - type, - children, - ...props -}: PropsWithChildren) { - const { color, icon } = styleMap[type]; - - return ( - -
-
{icon}
-
{children}
-
-
- ); -} - -const styleMap: { - [key in AlertProps['type']]: { color: String; icon: ReactElement }; -} = { - negative: { - color: 'red', - icon: ( - - - - - - ), - }, - positive: { - color: 'green', - icon: ( - - - - - ), - }, - warning: { - color: 'yellow', - icon: ( - - - - - - ), - }, - info: { - color: 'aqua', - icon: ( - - - - - ), - }, -}; diff --git a/packages/alert/src/index.ts b/packages/alert/src/index.ts deleted file mode 100644 index 8c4450cf..00000000 --- a/packages/alert/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { Alert } from './component'; -export type { AlertProps } from './props'; diff --git a/packages/alert/src/props.tsx b/packages/alert/src/props.tsx deleted file mode 100644 index 12b62dd2..00000000 --- a/packages/alert/src/props.tsx +++ /dev/null @@ -1,16 +0,0 @@ -export type AlertProps = { - /** - * Determines whether the alert should be visible - */ - show?: Boolean; - /** - * Type of alert - */ - type: 'negative' | 'positive' | 'warning' | 'info'; - /** - * Additional classes to include - */ - className?: string; - /** Additional CSS styles for the container. */ - style?: React.CSSProperties; -}; diff --git a/packages/alert/stories/Alert.stories.tsx b/packages/alert/stories/Alert.stories.tsx deleted file mode 100644 index 9dbf0bb3..00000000 --- a/packages/alert/stories/Alert.stories.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import React from 'react'; -import { Button } from '../../button/src'; -import { Alert } from '../src'; - -const metadata = { title: 'FeedbackIndicators/Alert' }; -export default metadata; - -export const Default = () => { - const [show, setShow] = React.useState(true); - - return ( -
-
-

Negative

- - This is a message that you've done something really wrong. - - -
-
-

Positive

- - This is a message that gives you positive feedback. - -
-
-

Warning

- - This is a message that shows a warning, might be nothing serious. - -
-
-

Info

- - This is a message that enlightens you with some new cool information. - -
-
- ); -}; - -const InteractiveContent = () => ( - <> -

This text attracts your attention right away

-

This is the message text that can be short or a little bit long

- Link to more information -
- - -
- -); - -export const WithInteractiveContent = () => { - const [show, setShow] = React.useState(true); - - return ( -
-
-

Negative

- - - - -
-
-

Positive

- - - -
-
-

Warning

- - - -
-
-

Info

- - - -
-
- ); -}; diff --git a/packages/box/src/component.tsx b/packages/box/src/component.tsx index fd20457b..bdacee7f 100644 --- a/packages/box/src/component.tsx +++ b/packages/box/src/component.tsx @@ -1,5 +1,5 @@ import { classNames } from '@chbphone55/classnames'; -import { box } from '@fabric-ds/css/component-classes'; +import { box } from '@fabric-ds/component-classes'; import React from 'react'; import { BoxProps } from './props'; diff --git a/packages/card/src/component.tsx b/packages/card/src/component.tsx index 50aa532a..42feb834 100644 --- a/packages/card/src/component.tsx +++ b/packages/card/src/component.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { card as c } from '@fabric-ds/css/component-classes'; +import { card as c } from '@fabric-ds/component-classes'; import { classNames } from '@chbphone55/classnames'; import { CardProps } from './props'; diff --git a/packages/expandable/src/component.tsx b/packages/expandable/src/component.tsx index 9280cdc0..566c6018 100644 --- a/packages/expandable/src/component.tsx +++ b/packages/expandable/src/component.tsx @@ -1,10 +1,7 @@ import { classNames } from '@chbphone55/classnames'; -import { - box as boxClasses, - buttonReset, -} from '@fabric-ds/css/component-classes'; -import React from 'react'; -import { ExpandTransition } from '../../_helpers'; +import { box as boxClasses, buttonReset } from '@fabric-ds/component-classes'; +import { collapse, expand } from 'element-collapse'; +import React, { useRef } from 'react'; import type { ExpandableProps } from './props'; export function Expandable(props: ExpandableProps) { @@ -24,11 +21,19 @@ export function Expandable(props: ExpandableProps) { ...rest } = props; + const boxRef = useRef(null); const [stateExpanded, setStateExpanded] = React.useState(expanded); const toggleExpandable = (state) => { setStateExpanded(!state); if (onChange) onChange(!state); + + if (!boxRef.current || !props.animated) return; + if (!state) { + expand(boxRef.current); + } else { + collapse(boxRef.current); + } }; return ( @@ -78,8 +83,14 @@ export function Expandable(props: ExpandableProps) { )} - - +
{children}
- -
- ); -} - -function ExpansionBehaviour({ animated, stateExpanded, children }) { - return animated ? ( - {children} - ) : ( -
- {children} +
); } diff --git a/packages/index.ts b/packages/index.ts index 8216fbda..492f3f6d 100644 --- a/packages/index.ts +++ b/packages/index.ts @@ -1,5 +1,4 @@ export * from './_helpers'; -export * from './alert/src'; export * from './box/src'; export * from './breadcrumbs/src'; export * from './attention/src'; diff --git a/packages/modal/docs/Modal.mdx b/packages/modal/docs/Modal.mdx index 5e843a4a..cb32adde 100644 --- a/packages/modal/docs/Modal.mdx +++ b/packages/modal/docs/Modal.mdx @@ -110,17 +110,9 @@ respond to `esc` keypresses and/or clicking outside the modal. ```jsx example function Example() { const [open, setOpen] = React.useState(false); - const [mustAgree, setMustAgree] = React.useState(false); const [hasAgreed, setHasAgreed] = React.useState(false); - const toggleModal = () => { - if (open && !hasAgreed) { - setMustAgree(true); - return; - } - setMustAgree(false); - setOpen(!open); - } + const toggleModal = () => setOpen(!open); return ( <> @@ -133,12 +125,9 @@ function Example() { onDismiss={hasAgreed ? toggleModal : undefined} title="Non dismissable" footer={ - <> - {mustAgree &&

You must agree first!

} - - + } >

To go further, you need to agree to these bogus terms

diff --git a/packages/modal/src/component.tsx b/packages/modal/src/component.tsx index 18fc46ea..616737ae 100644 --- a/packages/modal/src/component.tsx +++ b/packages/modal/src/component.tsx @@ -1,5 +1,5 @@ import { classNames } from '@chbphone55/classnames'; -import { modal as c } from '@fabric-ds/css/component-classes'; +import { modal as c } from '@fabric-ds/component-classes'; import React, { useEffect, useRef } from 'react'; import { useId } from '../../utils/src'; import FocusLock from 'react-focus-lock'; diff --git a/packages/steps/src/step.tsx b/packages/steps/src/step.tsx index ab7140e6..6169a9eb 100644 --- a/packages/steps/src/step.tsx +++ b/packages/steps/src/step.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { classNames } from '@chbphone55/classnames'; -import { step as c } from '@fabric-ds/css/component-classes'; +import { step as c } from '@fabric-ds/component-classes'; import { useContext } from 'react'; import { StepsContext } from './component'; diff --git a/packages/switch/src/component.tsx b/packages/switch/src/component.tsx index b893994d..b17f07a8 100644 --- a/packages/switch/src/component.tsx +++ b/packages/switch/src/component.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { SwitchProps } from './props'; import { classNames } from '@chbphone55/classnames'; -import { switchToggle as c } from '@fabric-ds/css/component-classes'; +import { switchToggle as c } from '@fabric-ds/component-classes'; export function Switch({ id, diff --git a/packages/tabs/src/component-tab-panel.tsx b/packages/tabs/src/component-tab-panel.tsx index 33706071..8a0561e0 100644 --- a/packages/tabs/src/component-tab-panel.tsx +++ b/packages/tabs/src/component-tab-panel.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { tab as c } from '@fabric-ds/css/component-classes'; +import { tab as c } from '@fabric-ds/component-classes'; import type { TabPanelProps } from './props'; export function TabPanel(props: TabPanelProps) { diff --git a/packages/tabs/src/component-tab.tsx b/packages/tabs/src/component-tab.tsx index 3343a492..b5273f91 100644 --- a/packages/tabs/src/component-tab.tsx +++ b/packages/tabs/src/component-tab.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { classNames as cn } from '@chbphone55/classnames'; -import { tab as c } from '@fabric-ds/css/component-classes'; +import { tab as c } from '@fabric-ds/component-classes'; import type { TabProps } from './props'; const setup = ({ diff --git a/packages/tabs/src/component-tabs.tsx b/packages/tabs/src/component-tabs.tsx index 0920881e..b9d86d58 100644 --- a/packages/tabs/src/component-tabs.tsx +++ b/packages/tabs/src/component-tabs.tsx @@ -6,7 +6,7 @@ import React, { Children, } from 'react'; import { classNames as cn } from '@chbphone55/classnames'; -import { tabs as c } from '@fabric-ds/css/component-classes'; +import { tabs as c } from '@fabric-ds/component-classes'; import { debounce } from './utils'; import type { TabsProps } from './props';