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

Flame v2 #99

Merged
merged 42 commits into from
Jul 17, 2020
Merged

Flame v2 #99

merged 42 commits into from
Jul 17, 2020

Conversation

xdrdak
Copy link
Contributor

@xdrdak xdrdak commented Jun 17, 2020

Description

Prepare for merging next into master to kick off v2.

Breaking

  • Use React.forwardRef on <Button> and <Switch> components (#75)
  • Title in Alert component is now required highly recommended (#82)
  • Swap out internals for usePopper, slight change in the API. See migration guide below

Deprecation Warning

  • Alert icon prop will be removed in the next major feature release. Icons will be automatically assigned to an alert based on the variant used (#82)
  • PillBadge will be removed
  • Badge "size" prop will be removed, "type" prop will be renamed to "variant" and Badge will no longer support styled-system props. Should you wish to adopt the new Badge, you may leverage next/Badge for an early migration.

Added

  • New AlertInCard component (#82)
  • Alert component will now automatically inject the right icons as per DSD specs. Overrides still possible, but will be removed at the next major bump (#82)
  • New Toaster component (#86)
  • Added 'next/Badge' component. (#106

Fixed

  • Icons in Alert will now automatically assign the right color that matches the type of Alert (#82)
  • Icons in Alert will now be properly centered (#82)
  • Tweak css selectors for TextContent to adapt to how emotion handles specificities (#92)
  • Input now has type="text" applied by default (#117)

Migration

usePopper

  • Swap out internal usePopper hook with the one provided by react-popper. While the the underlying components API have not changed, if you are using the hook directly, you'll need to swap out a couple of things to fit the react-popper's hook. Namely, the target and popper refs need to come from the React.useState hook. Additionally, the styles need to be manually applied.(#104
// Before
const Component = () => {
  const targetRef = React.createRef(null);
  const popperRef = React.createRef(null);
  // placement contains the positioning of the popper
  const { placement } = usePopper(targetRef, popperRef);

  return (
    <div>
      <div ref={targetRef}>target</div>
      <div ref={popperRef}>popper content</div>
    </div>
  );
};

// After
import { usePopper } from '@lightspeed/flame/hooks';

const Example = () => {
  const [targetRef, setTargetRef] = React.useState(null);
  const [popperRef, setPopperRef] = React.useState(null);
  // attributes.popper['data-popper-placement'] effectively fills the same role as
  // the previously provided placement return value.
  // long story short: attributes.popper['data-popper-placement'] === placement
  const { styles, attributes } = usePopper(targetRef, popperRef);

  return (
    <div>
      <div ref={setTargetRef}>target</div>
      <div ref={setPopperRef} style={styles.popper}>
        popper content
      </div>
    </div>
  );
};

Additionally, should you leverage the useOnClickOutside hook in conjunction with usePopper, you'll need to also forward a separate ref.

import { usePopper, useOnClickOutside } from '@lightspeed/flame/hooks';

const Example = () => {
  const [targetRef, setTargetRef] = React.useState(null);
  const [popperRef, setPopperRef] = React.useState(null);
  const clickOutsideRef = React.useRef();
  clickOutsideRef.current = popperRef;
  const { styles } = usePopper(targetRef, popperRef);

  useOnClickOutside(clickOutsideRef, () => console.log('clicked outside!'));

  return (
    <div>
      <div ref={setTargetRef}>target</div>
      <div ref={setPopperRef} style={styles.popper}>
        popper content
      </div>
    </div>
  );
};

How to test?

  • Checkout branch, run yarn dev
  • Open Storybook
  • Or check the deploy preview on Netlify (link available in comments)

Checklist

@netlify
Copy link

netlify bot commented Jun 17, 2020

Deploy preview for lightspeed-flame ready!

Built with commit c08146e

https://deploy-preview-99--lightspeed-flame.netlify.app

@netlify
Copy link

netlify bot commented Jun 17, 2020

Deploy preview for lightspeed-flame ready!

Built with commit 38a510d

https://deploy-preview-99--lightspeed-flame.netlify.app

@xdrdak
Copy link
Contributor Author

xdrdak commented Jun 29, 2020

Flushing the old notifications by closing this PR

xdrdak and others added 24 commits July 6, 2020 12:34
* Add AlertInCard component. Auto color for Alert icons.

* Update Alert/readme.md

* Update CHANGELOG.md

* Remove useless generic in getTheme

* tiny fixes to match design specs

* Update typing ignores

* design feedback. remove useless typing

* hush now codecov

* Force add DSD specific icons if prop not filled

* PR feedback

Co-authored-by: maartenafink <[email protected]>
Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-node) from 0.1.3 to 0.1.4. **This update includes a security fix.**
- [Release notes](https://github.com/faye/websocket-extensions-node/releases)
- [Changelog](https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md)
- [Commits](faye/websocket-extensions-node@0.1.3...0.1.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Forward ref on remaining base components

* adjust changelog

Co-authored-by: Guillaume Lambert <[email protected]>
* Add toaster component WIP

* Update jest and testing-library. Tests for toaster

* Update toaster readme

* remove dangling TODO from toaster

* Add better responsiveness for Toaster

* Restrict Toaster types. Bypass click events for ToasterContainer

* Update changelog. Add notice that we are using an external lib

* Remove unused typing file

* Spread rest on Toaster component to auto-pause timer

* Update toaster behaviour to match specs

* Supress warnings for logs. Fix toaster example setup

* less jarring height transition

* fixing text alignment

* Set minHeight for container at 60px

* Test out Percy with animations

Co-authored-by: maartenafink <[email protected]>
Co-authored-by: Guillaume Lambert <[email protected]>
* port over previous tokens stories. Adapt for flame

* Move dependencies to relevant package

* disable css modules as its not really relevant anymore

* update popover and tooltip story styling. sort top level sections

* skip theme percy snapshots as per old implementation

* Remove dead deps. Bubble ExampleBox from popover and tooltip

* Move stories/ into flame/.storybook. Cleanup useless test

* Fix percy command

* Fix weird regression due to injecting components in style tags

* Display themeGet and css for colours instead of classnames

* Fix spaced group

* Colours -> Colors

* remove superflous react devDep

* leverage top level packages

Co-authored-by: Guillaume Lambert <[email protected]>
Bumps [acorn](https://github.com/acornjs/acorn) from 6.4.0 to 6.4.1. **This update includes security fixes.**
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](acornjs/acorn@6.4.0...6.4.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Xavier Drdak <[email protected]>
* Adjust lineheight in Alert to be normal.

* Update changelog
* Fix Alert and AlertInCard typing. Allow empty title

* Update changelog
* Leverage react-popper usePopper hook

* remove old popper dependency

* update changelog

* fix lint
xdrdak and others added 14 commits July 6, 2020 12:35
* add forceUpdate to Dropdown and Popover

* Replace forceUpdate with update. Fix clickOutside hook

* Update CHANGELOG.md
* set higher zIndex for ToasterContainer

* Update CHANGELOG.md
* add next/Badge component

* fix colors for oldskool theme

* Update CHANGELOG.md

* Let percy snapshot next

* Use variant prop instead of type for badge

* Update CHANGELOG.md

* Adjust padding based on design feedback

* Fix storybook publishing

Co-authored-by: Guillaume Lambert <[email protected]>
* Smoothed out border-radius for next/Badge

* Update CHANGELOG.md
* export typing for next/Badge

* Update CHANGELOG.md
* Port sass as is into flame

* Apply suggestions from code review

Co-authored-by: Guillaume Lambert <[email protected]>

* Update css README docs. Remove media queries css as this is out of scope

* Remove private flag from flame-css

Co-authored-by: Guillaume Lambert <[email protected]>
 - @lightspeed/[email protected]
 - @lightspeed/[email protected]
* move everything back to root

* strip magic from storybook-components. Adjust root package scripts

* Mute typings for withReadme

* Fix netlify build path

* Fix storybook decorator injection condition
…ing (#115)

* Target tags for action. Snapshot on label

* Pushes on master will trigger a snapshot
@xdrdak xdrdak marked this pull request as ready for review July 17, 2020 12:58
@xdrdak xdrdak requested a review from a team as a code owner July 17, 2020 12:58
@xdrdak xdrdak merged commit bd71884 into master Jul 17, 2020
@glambert glambert mentioned this pull request Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants