Coder Social home page Coder Social logo

ebay / ebayui-core-react Goto Github PK

View Code? Open in Web Editor NEW
27.0 9.0 29.0 11.96 MB

eBayUI React components

Home Page: https://opensource.ebay.com/ebayui-core-react/main/

License: MIT License

JavaScript 1.97% TypeScript 98.01% HTML 0.01% Shell 0.01%
components ebay react ebayui

ebayui-core-react's Introduction

ebayui-core-react

eBayUI React components

Demo

Requirements

eBayUI Components

Getting Started

These react components are available as @ebay/ui-core-react package on NPM.

Use npm or yarn to add the package dependency to your project:

yarn add @ebay/ui-core-react

for quick development/POC

import { EbayTextbox, EbayButton } from '@ebay/ui-core-react'

<EbayTextbox placeholder="Enter text here" />
<EbayButton>Submit</EbayButton>

for smaller bundle size

import { EbayTextbox } from '@ebay/ui-core-react/ebay-textbox'
import { EbayButton } from '@ebay/ui-core-react/ebay-button'

<EbayTextbox placeholder="Enter text here" />
<EbayButton>Submit</EbayButton>

Notes

If you render children components dynamically and don't want to get React key warnings then provide a key:

<EbayParentComponent>
    {items.map((item, index) => <EbayChildComponent key={index}>{item}</EbayChildComponent>)}
</EbayParentComponent>

Pass-Through Attributes

HTML attributes can be used on any component, and they will be passed through to the most prominent tag of the component. The most prominent tag is usually the root or form control, but individual components will note if it varies for specific cases.

Example of usage:

<EbayButton id="my-button" />

Issues

Create an issue on github

Changelog

@ebay/ui-core-react

version 5.x (Skin 16, breaking changes in event callbacks)

version 4.x (Skin 16, breaking changes in icon names)

version 3.x (Skin 15, some breaking changes in dialog components)

version 2.x (Skin 15)

@ebay/ebayui-core-react

version 10.x (Skin 14)

version 9.x (skin 13)

ebayui-core-react

version 8.x (skin 12)

version 6.x (skin 10)

version 5.x (removed less, changed imports to minimize bundle size)

version 3.x (skin 9, react 16.8 with hooks support)

version 2.x (skin 7, react 16.7)

legacy

ebayui-core-react's People

Contributors

aaron-nance avatar abhigyan-pandey avatar abiyasa avatar bjoernr-de avatar calebnance avatar darkwebdev avatar dependabot[bot] avatar don-siu avatar fiodorgherasimenco avatar flakronkadriu avatar guilherme-n avatar henriquelimas avatar joinfelipe avatar kristopherrollert avatar marcial199545 avatar maxrchung avatar mlrawlings avatar montoya332 avatar oxala avatar praveengh1 avatar raveenakothapally avatar renka avatar rglombov avatar shpandian avatar vshrivastav13 avatar ykabisher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ebayui-core-react's Issues

Accessibility: EbaySectionNotice section not being announced by screen readers

EbaySectionNotice section region (role="region") is linking to a description empty element( id="section-notice-attention" element only contains a );

Screen Shot 2022-08-29 at 12 50 34 PM

The expected behavior is: "The region has an accessible name that it announced when the region is focused." - while currently the region is not announced by screen readers.

Optional but would be nice if we utilize Storybook action addon which we already use on some components. This is quite handy to do a quick manual test on storybook, making sure important handlers are called.

Original issue: https://github.corp.ebay.com/React/ebayui-core-react/issues/358

Optional but would be nice if we utilize Storybook action addon which we already use on some components. This is quite handy to do a quick manual test on storybook, making sure important handlers are called.

// add import
import { action } from '../../../.storybook/action'

export const _Default = () => {
    // add 2 handlers with action
    const handleConfirm = () => {
        action('onConfirm')();
        close();
    }
    const handleReject = () => {
        action('onReject')();
        close();
    }

    return (
        <div>
          { /* ... */ }
          { /* Add handlers to component, one can see the action name on Storybook addons panel */ }  
        <EbayConfirmDialog 
            open={open}
            onConfirm={handleConfirm}
            onReject={handleReject}
        >
              { /* ... */ }  
        </EbayConfirmDialog>
    </div>
)};

Originally posted by @isuhardi in https://github.corp.ebay.com/React/ebayui-core-react/pull/351#discussion_r2149916

ebay-select: TypeScript compilation error with onChange

When EbaySelect with onChange used with TypeScript, I got compilation error due to conflicting types:

error TS2322: Type '(e: ChangeEvent<HTMLSelectElement>, selectedIndex: number, newValue: string | number | readonly string[]) => void' is not assignable to type 'ChangeEventHandler<HTMLSelectElement> & ((e: ChangeEvent<HTMLSelectElement>, selectedIndex: number, newValue: SelectValue) => void)'.
  Type '(e: ChangeEvent<HTMLSelectElement>, selectedIndex: number, newValue: string | number | readonly string[]) => void' is not assignable to type 'ChangeEventHandler<HTMLSelectElement>'.

59         onChange={handleSelectChange}
           ~~~~~~~~

  node_modules/@types/react/index.d.ts:2375:9
    2375         onChange?: ChangeEventHandler<T> | undefined;
                 ~~~~~~~~
    The expected type comes from property 'onChange' which is declared here on type 'IntrinsicAttributes & ClassAttributes<HTMLSelectElement> & SelectHTMLAttributes<HTMLSelectElement> & { ...; } & { ...; }'

How to reproduce

  • Use any TypeScript (tested with 3.9 and 4.6) with the latest type definitions for react v16.14.30.
  • Add EbaySelect with onChange
const handleSelectChange: (
  e: React.ChangeEvent<HTMLSelectElement>,
  selectedIndex: number,
  newValue: string | ReadonlyArray<string> | number
) => void = (event, selectedIndex, newValue) => {
  // ....
}

// ...
<EbaySelect
  name="endReason"
  onChange={handleSelectChange}
>
  {benefits.map((benefit, index) => 
    <EbaySelectOption key={index} value={benefit.value}>
      {benefit.title}
    </EbaySelectOption>
  )}
</EbaySelect>

Cause

This is due to conflicting types between:

  • HTML select onChange with type ChangeEventHandler<HTMLSelectElement> (1 parameter)
  • EbaySelect onChange with type (e: ChangeEvent<HTMLSelectElement>, selectedIndex: number, newValue: string | number | readonly string[]) => void (3 parameters)

EbaySelect used all select props and try to overwrite its onChange:

export type EbaySelectProps = ComponentProps<'select'> & {
borderless?: boolean;
defaultValue?: SelectValue;
onChange?: (e: ChangeEvent<HTMLSelectElement>, selectedIndex: number, newValue: SelectValue) => void;
floatingLabel?: string;
inputSize?: 'default' | 'large';
invalid?: boolean;
};

We should omit onchange from EbaySelect before overwriting it. See https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_usecase/#props-omit-prop-from-a-type

Workaround

Cast the handler with ChangeEventHandler:

<EbaySelect
  name="endReason"
  onChange={handleSelectChange as React.ChangeEventHandler<HTMLSelectElement>}
>

ebay-tab: Accessibility bug due to duplicated IDs when a page has more than 1 tab

Problems

  • When there are more than 1 ebay-tabs on a page, the page will get accessibility error (via Chrome lighthouse) due to duplicated ebay-tab IDs.
  • Unfortunately, there is no workaround for this issue

How to Reproduce

Cause

This is due to hardcoded id on nesting tab, which will always have semi-dynamic id default-tab-{child-tab-index}:

<div
{...rest}
ref={refCallback}
aria-controls={`default-tabpanel-${index}`}
aria-selected={selected}
className={classNames(className, 'tabs__item')}
id={`default-tab-${index}`}
role="tab"
tabIndex={selected ? 0 : -1}
onClick={onClick}
onKeyDown={onKeyDown}
>

Possible Fix

Use prefix ID for nested tab id instead of just default-tab-${index}. We can get prefix id from the EbayTab id (if provided by consumer). This pattern is used on other components like dialogs or breadcrumbs.

Add Contributing.md

Add a separated CONTRIBUTING.md, which is common practice for having contribution guideline on public GitHub (see https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/setting-guidelines-for-repository-contributors)

  • Split contributions from README
  • We should state in details what we want to have for when people contribute to the project:

@darkwebdev @HenriqueLimas We can use this issue to discuss what we want to have

Use React v16 on both dev and peer dependencies

Problem

Currently, eBayUI Core React only support React v16 via its peer dependency:

"peerDependencies": {
"@ebay/skin": "^14.0.0",
"react": "^16.0.0",
"react-dom": "^16.0.0"
},

However, on its devDependencies , we use v18 for react, types/react, react-dom, and types/react-dom. I think this will cause problem since eBayUI Core React will be compiled using type definitions for React v18, while the consumer is still on v16. There might be new React attributes or props on the compiled type definitions.

Proposed Solution

One options is to use React v16 for both peer and dev dependencies, for now. When we upgrade support to React v18, then we will update both peer and dev dependencies to use v18.

Cleanup: Removed all deprecated features on next major release

We should removed all deprecated components, props, and enums on the next major release, maybe on the next Skin upgrade.

Besides removing, we must document it on the release note. For example, deprecating EbayDialog in favour of EbayFullscreenDialog, EbayLightboxDialog, and so on.

List

The following is the features to be removed. Feel free to add more so we can remove the following in one go.

Components

  • EbayDialog. Replaced by EbayFullscreenDialog, EbayLightboxDialog, EbayPanelDialog, and EbayDrawerDialog
  • EbayFloatingLabel. Replaced by using EbayTextbox or EbaySelect with propfloatingLabel.
  • EbayLegacyFloatingLabel.
  • EbayNoticeContent in src/ebay-notice-content. Replace by importing EbayNoticeContent from component ebay-notice-base, ebay-page-notice, ebay-section-notice, or ebay-inline-notice.
  • EbayTab. Replaced by EbayTabs.

Component Props

  • EbayFullscreenDialog prop sliding.
  • EbayButton priority="delete". Replaced by EbayButton prop variant ="destructive".
  • EbayTabs fake.
  • EbayTextbox underline
  • EbayProgressStep number. Replaced by property state.

Component Constants and Enums

  • From tooltip-utils constants-legacy TOOLTIP_TYPES and POINTER_TYPES. Replaced by TooltipType union type.
  • EbayField fieldLayoutType, fieldDescriptionType, and fieldDescriptionPosition. Replaced by union types FieldLayoutType, FieldDescriptionType, and FieldDescriptionPosition.
  • EbayInfotip enums variants. Replaced by Variant union type.
  • EbayTab activations and sizes. Replaced by EbayTabs.

Introduce prettier and split linting and code styling

Introduce prettier for code styling formatting. This is not just introducing prettier to our dependency and build process but more than that!

Splitting code stye formatting (prettier) with linting for code quality rules (eslint)

The idea that we should not care and waste our time discussing about code styling and delegate/automate that matters to prettier. This will free us more time and energy to discuss more important stuff. See https://www.morling.dev/blog/the-code-review-pyramid/ about this common phenomenon on code review

  • This means that our eslint rules should focus on code quality and contains rules to prevent bugs (e.g no unused vars, no implivit globals, prefer const, ...).
  • Any code styling rules (e.g trailing coma, space, quotes, white space) should be handled by prettier.
  • For motivation on splitting linting and code styling, see https://prettier.io/docs/en/comparison.html

Preferable to use the default prettier config as-is

Again, this is to delegate anything related to code styling to prettier. As soon as we add prettier config, even if it's just a small config, it might start discussions about 2-vs-4 spaces, single vs double quotes, ...

People will then focus and invested on discussions around mundane aspects like code style formatting, whereas more important aspects (does the code change do what it is supposed to do, is it performant, is it backwards-compatible for existing API, do we write good tests, and many others) tend to get less attention. See https://www.morling.dev/blog/the-code-review-pyramid/

Drop eslint-config-ebay

eslint-config-ebay is based on airbnb eslint rules which is a mix of code styling (and very opinionated about it) and bug-prevention rules. Unfortunately the eBay rule is not maintained since 2019, some rules might outdated, not in-synch with AirBnB anymore, and does not consider for the latest ES6+ (e.g ES2022) and TypeScript.

  • Would drop eslint-config-ebay and stick with recommended eslint rules (e.g eslint:recommended, @typescript-eslint/eslint-recommended, react/recommended) and add more rules to help us catching bugs (e.g react-hooks/recommended)

Others

  • Include prettier as-part of husky or lint-staged

ebay-radio: TypeScript compilation error with onChange

Similar to issue #75, I got TypeScript compilation error when using EbayCheckbox with onChange:

error TS2322: Type '(e: ChangeEvent<HTMLInputElement>, value: string | number, checked: boolean) => void' is not assignable to type 'ChangeEventHandler<HTMLInputElement> & ((e: ChangeEvent<HTMLInputElement>, value: string | number, checked: boolean) => void)'.
  Type '(e: ChangeEvent<HTMLInputElement>, value: string | number, checked: boolean) => void' is not assignable to type 'ChangeEventHandler<HTMLInputElement>'.

68       <EbayCheckbox checked value="123" id="checkbox-21" onChange={handleCheckboxChange}>
                                                            ~~~~~~~~

  node_modules/@types/react/index.d.ts:2221:9
    2221         onChange?: ChangeEventHandler<T> | undefined;
                 ~~~~~~~~
    The expected type comes from property 'onChange' which is declared here on type 'IntrinsicAttributes & InputProps & EbayCheckboxProps & { children?: ReactNode; }'

How to reproduce

  • Use any TypeScript (tested with 3.9 and 4.6) with the latest type definitions for react v16.14.30.
  • Add EbayCheckbox with onChange
const handleCheckboxChange: (
  e: React.ChangeEvent<HTMLInputElement>, value: string | number, checked: boolean
) => void = (event, selectedIndex, newValue) => {
   // ...
}

// ...
<EbayCheckbox checked value="123" id="checkbox-21" onChange={handleCheckboxChange}>
  <EbayLabel>Default</EbayLabel>
</EbayCheckbox>

Cause

This is due to conflicting types between:

  • HTML input onChange with type ChangeEventHandler<HTMLInputElement> (1 parameter)
  • EbaySelect onChange with type (e: ChangeEvent<HTMLInputElement>, value: string | number, checked: boolean) => void (3 parameters)

EbayCheckbox used all <input> props and try to overwrite its onChange:

type InputProps = Omit<ComponentProps<'input'>, 'size'>
type EbayCheckboxProps = {
size?: Size;
onChange?: (e: ChangeEvent<HTMLInputElement>, value: string | number, checked: boolean) => void;
}

We should omit onchange from EbayCheckbox before overwriting it. See https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_usecase/#props-omit-prop-from-a-type

Workaround

Cast the handler with ChangeEventHandler:

<EbayCheckbox
  onChange={handleCheckboxChange as React.ChangeEventHandler<HTMLInputElement>}
>

EbayFilter

Marko Source, Storybook

Original eBayUI API compatibility:

  • DOM structure of the component is preserved
  • All original attributes are supported
  • All original events are triggered

Documentation & tests:

  • Readme
  • Rendering tests (snapshots/manual)
  • Interaction tests (clicking, etc)
  • Storybook has examples with multiple use-cases

Bug: Storyshots did not create test snapshot for all storybook

Problems

While modifying the ebay-button, I realized that the StoryShots did not create test snapshot for all Storybook stories.

Here's one of the ebay-button story. It contains 2 buttons:

.add(`Default`, () => (
<>
<p><EbayButton
onClick={action(`clicked`)}
onEscape={action('escape pressed')}
>Hello, I am a button!</EbayButton></p>
<p><EbayButton href="https://ebay.com">Hello, I am a link!</EbayButton></p>
</>
))

Meanwhile, the snapshot from that story only containing 1 button:

exports[`Storyshots ebay-button Default 1`] = `
<p>
<button
class="btn btn--secondary"
>
Hello, I am a button!
</button>
</p>
`;

The same with other longer story:

.add(`Priority`, () => (
<>
<p><EbayButton priority="primary">Primary Button</EbayButton></p>
<p><EbayButton priority="primary" href="https://ebay.com">Primary Link</EbayButton></p>
<p><EbayButton priority="secondary">Secondary Button</EbayButton></p>
<p><EbayButton priority="secondary" href="https://ebay.com">Secondary Link</EbayButton></p>
<p><EbayButton>Secondary Button (Default)</EbayButton></p>
<p><EbayButton href="https://ebay.com">Secondary Link (Default)</EbayButton></p>
<p><EbayButton priority="tertiary">Tertiary Button</EbayButton></p>
<p><EbayButton priority="tertiary" href="https://ebay.com">Tertiary Link</EbayButton></p>
<p><EbayButton priority="delete">Delete Button</EbayButton></p>
<p><EbayButton priority="none">Base Button</EbayButton></p>
</>
))

The snapshot only capture the first button:

exports[`Storyshots ebay-button Priority 1`] = `
<p>
<button
class="btn btn--primary"
>
Primary Button
</button>
</p>
`;

This is a big problem since our test coverage might be lower than we thought.

Cause

However, this problem only existed if we wrap a Storybook story with React Fragment. If we wrap it with a <div> of <p>, the Storyshots capture the whole story.

For an example, this story is wrapped by a <div>:

.add(`Transparent`, () => (
<div style={{ background: 'rgba(66, 214, 205, 0.5)' }}>
<p><EbayButton>Default Button</EbayButton></p>
<p><EbayButton transparent>Transparent Button</EbayButton></p>
<p><EbayButton transparent priority="delete">Transparent Delete Button</EbayButton></p>
<p><EbayButton href="https://ebay.com" transparent>Transparent Link</EbayButton></p>
</div>
))

The generated snapshot contains all buttons:

exports[`Storyshots ebay-button Transparent 1`] = `
<div
style="background: rgba(66, 214, 205, 0.5);"
>
<p>
<button
class="btn btn--secondary"
>
Default Button
</button>
</p>
<p>
<button
class="btn btn--secondary btn--transparent"
>
Transparent Button
</button>
</p>
<p>
<button
class="btn btn--delete btn--transparent"
>
Transparent Delete Button
</button>
</p>
<p>
<a
class="fake-btn fake-btn--secondary fake-btn--transparent"
href="https://ebay.com"
>
Transparent Link
</a>
</p>
</div>
`;

I suspect this has thing to do our StoryShot configuration, which only take snapshot from the first child:

const reactTestingLibrarySerializer = {
print: (val, serialize, indent) => serialize(val.container.firstChild),
test: (val) => val && val.hasOwnProperty("container"),
};

Options so far:

  • We might have to take snapshot of the whole container, but it might pollute our snapshot with react-testing-library container
  • We have to replace all React Fragment on Storybook wrapper with other element like <div>

EbayCombobox

Marko Source, Storybook

Original eBayUI API compatibility:

  • DOM structure of the component is preserved
  • All original attributes are supported
  • All original events are triggered

Documentation & tests:

  • Readme
  • Rendering tests (snapshots/manual)
  • Interaction tests (clicking, etc)
  • Storybook has examples with multiple use-cases

Should add invalid background color here

Original issue: https://github.corp.ebay.com/React/ebayui-core-react/issues/393

// input background in Skin 12, used for autofill detection
const textboxElementBackgroundRGB = [
'rgb(245, 245, 245)', // DEPRECATED
'rgb(247, 247, 247)' // From skin version 12.6.0
]

When field is invalid, the background color isrgb(254, 245, 246). Currently, for invalid floating label or floating select, if value is not set, the label will always be floated, which should be inline.

ebay-page-notice: Update icon size based on Skin v14.12.0

Skin v14.12.0 contains changes on Page Notice which make the icon smaller and some adjusted spacing.

Since the page notice icon is rendered by our ebay-icon, we need to change our implementation to use the right icon sizes:

<div className="page-notice__header" id={`${status}-status`}>
<EbayIcon
name={`${status}-filled` as any}
a11yText={ariaLabel}
a11yVariant="label"
/>
</div>

Before:

Before Skin v14.12.0

After:

After Skin v14.12.0

See related issues:

add storybook action to tests for new dialogs

Feel free to also add storybook action to test onConfirm is being called, but I think it's not necessary, unlike the confirm dialog

From internal GH:

While adding storybook, maybe also improve unit test. Followup from my comment on improving ebay-confirm-dialog test https://github.corp.ebay.com/React/ebayui-core-react/pull/351#discussion_r2149911:

let wrapper
// Replace with these 2 handlers
let handleConfirm
let handleReject

beforeEach(() => {
    handleConfirm = jest.fn()
    handleReject = jest.fn()

    wrapper = mount(
        <EbayConfirmDialog
            open
            onReject={handleReject}
            onConfirm={handleConfirm}
        >
            { /* ... */ }
        </EbayConfirmDialog>
    )
})

// ...

// add 2 tests
it('should trigger onReject when reject button button is clicked', () => {
    wrapper.find(`button.confirm-dialog__reject`).simulate('click')
    expect(handleReject).toBeCalled()
    expect(handleConfirm).not.toBeCalled()
})

it('should trigger onConfirm when confirm button button is clicked', () => {
    wrapper.find(`button.confirm-dialog__confirm`).simulate('click')
    expect(handleConfirm).toBeCalled()
    expect(handleReject).not.toBeCalled()
})

Delete button is not rendered properly with Skin v14

Problem

Since Skin 14 and eBayUI Core v10, the delete button is not rendered properly: the button with red border is now rendered as default button with black border:

Screenshot 2022-07-13 at 20 51 27

Causes

With Skin 14, the delete button is now called destructive buttons. Instead of just 1 kind of button, there are 3 types of destructive buttons:

Screenshot 2022-07-13 at 20 54 07

  • The CSS modifier has changed from btn--delete to btn--destructive.
  • Apart from CSS class btn--destructive, we need to add btn--primary, btn--secondary, or btn--tertiary in order to render the button correctly.

ebay-star-rating and ebay-star-rating-select

Description

New component based on eBay/skin#1725

https://github.com/eBay/ebayui-core/tree/master/src/components/ebay-star-rating
and
https://github.com/eBay/ebayui-core/tree/master/src/components/ebay-star-rating-select

Original eBayUI API compatibility:

  • DOM structure of the component is preserved
  • All original attributes are supported
  • All original events are triggered

Documentation & tests:

  • Readme
  • Rendering tests (snapshots/manual)
  • Interaction tests (clicking, etc)
  • Storybook has examples with multiple use-cases

EbaySectionNotice section not being announced by screen readers

Original issue: https://github.corp.ebay.com/React/ebayui-core-react/issues/397

EbaySectionNotice section region (role="region") is linking to a description empty element( id="section-notice-attention" element only contains a <svg>);

image

Following the solution reported in https://jirap.corp.ebay.com/browse/APOLLO-3398 and https://jirap.corp.ebay.com/browse/APOLLO-3395, the expected behavior is: "The region has an accessible name that it announced when the region is focused." - while currently the region is not announced by screen readers.

Issue created on ebayui-app-react: React/ebayui-app-react#152

Add eslint plugins & rules for hooks

Original issue: https://github.corp.ebay.com/React/ebayui-core-react/issues/277

Add the official eslint rules for React hooks (see https://reactjs.org/docs/hooks-rules.html and https://www.npmjs.com/package/eslint-plugin-react-hooks) to our eslint config.

This is to prevent hooks-related issues like https://github.corp.ebay.com/React/ebayui-core-react/issues/276 and https://github.corp.ebay.com/React/ebayui-core-react/issues/347, where we got stale props due to not properly stating variables on hook dependency array. This problem is hard to detect and also not easy to test.

README: Document about pass-through attributes feature

Original issue: https://github.corp.ebay.com/React/ebayui-core-react/issues/387

Just like the eBayUI Core Marko principles, eBayUI Core React also supports all valid HTML attributes on all its components (e.g id, aria-*, data-*, tabindex, style, ...) by using pass through feature.

The Marko has documented this feature on its readme (see https://github.com/eBay/ebayui-core#pass-through-attributes) but not on our React part.

Adding this feature to our document will help to solve questions/problems like this on Slack especially for new users, who are not familiar with eBayUI Core Marko and not aware that most eBayUI Core component supports any HTML attributes.

Clean-up release and git tags

When renaming the repo to ui-core-react (see PR #57 ), we reset the version back to version 1.0.0

There are currently 80+ release tags from the old releases, when we're still using the old name. These old tags potentially can break our release in the future. The new version might clash with the existing older version so version bumping will failed since the git tag has already existed.

While this version clash will happen somewhen in the future when we reach version 9.13 but it's best if we clean up git tags earlier.

Actions

We can delete the following tags or rename them to [email protected]:

Upgrade storybook with addons

Original issue: https://github.corp.ebay.com/React/ebayui-core-react/issues/268

  • @storybook/react should be 6+
  • @storybook/addon-storyshots should be 6+

documentation: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-configure

Both render and config properties will be deprecated in v6 and removed in v7:

initStoryshots({
    renderer: mount,
    config: ({ configure }) =>
        configure(() => {
            require('./index.stories')
        }, module)
})

possible changes in jest.config.js:

{
transform: {
        '^.+\\.[jt]sx?$': 'ts-jest'
    },
globals: {
        'ts-jest': {
            tsConfig: {
                allowJs: true
            }
}

Replace static id on EbayListboxButton in case of prefixId is defined

Problems

As a follow up from PR #252, which used static id on the button span when the EbayListboxButton has prefixId (see this comment). The use of static id will cause another accessibility issue if we have more than 1 EbayListboxButton on the same page (more than 1 element with the same id).

Marko widget/component has the concept of 'key' where it can automatically generate unique id for an HTML element. React does not have this out-of-the-box (see issue #210).

Solutions

Please replace static id with dynamic id. However, please take in mind that we can't use random id here since it will cause problem when you re-hydrate a server-side-rendered page on browser.

Related Issues

The solution is related to issue #210

EbayDrawer: Cannot change expandable at runtime

When EbayDrawer Dialog expandable prop is changed while the dialog being shown, it does not cause the dialog to re-render.

How to reproduce

Create a storybook:

export const _TriggerExpanded = () => {
  const [open, setOpen] = useState(false);
  const [expanded, setExpanded] = useState(false);

  return (
    <>
      <EbayButton onClick={() => setOpen(!open)}>Open Drawer</EbayButton>
      <EbayDrawerDialog open={open} onClose={() => setOpen(false)} expanded={expanded}>
        <p>
          Trigger Dialog Expanded programmatically.
        </p>

        <EbayButton onClick={() => setExpanded(!expanded)} priority="secondary">
          {expanded ? "Collapse Drawer" : "Expand Drawer"}
        </EbayButton>
      </EbayDrawerDialog>
    </>
  );
};

Once the Drawer is displayed, you cannot expand or collapse the dialog when you click the dialog button "Expand Drawer".

Screenshot 2022-07-20 at 18 02 39

Expected

If I create a similar story on https://github.com/eBay/ebayui-core, you can change the drawer dialog expandable while having the dialog shown

<ebay-drawer-dialog
    a11y-close-text='Close drawer'
    aria-labelledby='drawer-title'
    open=state.open
    on-close('closeDrawer')
    on-expanded('emit', 'expanded')
    on-collapsed('emit', 'collapsed')
    on-open('emit', 'open')
    expanded=state.expanded>

    <@header#drawer-title>Heading Text</@header>

    <p>Trigger Dialog Expanded programmatically.</p>

    <@footer>
        <ebay-button on-click('triggerExpand')>
            ${state.expanded ? 'Collapse Drawer' : 'Expand Drawer'}
        </ebay-button>
    </@footer>
</ebay-drawer-dialog>

<ebay-button on-click('openDrawer')>Open drawer</ebay-button>
class {
    onCreate() {
        this.state = { open: false, expanded: false };
    }
    openDrawer() {
        this.state.open = true;
    }
    triggerExpand() {
        this.state.expanded = !this.state.expanded;
    }
    closeDrawer() {
        this.state.open = false;
        this.emit('close', arguments);
    }
}
drawer-expandable.mov

Dialog : aria-live defaulting to polite

EbaySvg: allow to include/exclude certain icons

We need to provide some props for including only required icons in the resulting SVG. Another way is to include all icons (like it works now) but exclude some that are not needed.

Example:

type Props = {
  include?: Icon[];
  exclude?: Icon[];
}
<EbaySvg include={['calendar', 'chevronUp', 'chevronDown']} />
<EbaySvg exclude={['calendar', 'chevronUp', 'chevronDown']} />

Small nuance:
EbaySvg component is generated by scripts/update-icons.js

Contributing document

For a good open source project (public or internal), it would be nice to have a guideline on how to contribute to this project. Things should be cover on the document:

  • System requirements
  • Branching strategy
  • PR requirements:
    • Unit tests
    • Storybook
    • Update component readme
    • TypeScript type definitions
    • Pass the build (lint, unit test, ...)
  • Defintion of Done:
    • Comply to DS6, Skin, Playbook
    • Code review
  • Release process:
    • Versioning
    • Breaking changes
    • Steps to release
    • Update Storybook

For start, we can have similar contributing guideline as the one from eBay UI Core Marko (https://github.com/eBay/ebayui-core/blob/master/CONTRIBUTING.md)

Extend test for EbayDialog

As a follow up for bugfix on aria-hidden: https://github.corp.ebay.com/React/ebayui-core-react/pull/120#issuecomment-1329665

The test should test if the aria-hidden is set accordingly in case of dialog is open and closed. Possible test case:

  • mount dialog with other divs
mount(
  <>
    <div id="test-1"/>
    <div id="test-2"/>
    <EbayDialog>...</EbayDialog>
    <div id="test-3"/>
  </>
)
  • Assert no aria-hidden on test divs
  • trigger dialog to show
  • Assert aria-hidden=true on test divs
  • trigger dialog to close
  • Assert no aria-hidden on test divs

ebay-carousel

Original implementation

Original eBayUI API compatibility:

  • DOM structure of the component is preserved
  • All original attributes are supported
  • All original events are triggered

Documentation & tests:

  • Readme
  • Rendering tests (snapshots/manual)
  • Interaction tests (clicking, etc)
  • Storybook has examples with multiple use-cases

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.