Coder Social home page Coder Social logo

seanmcp / a11y-react-emoji Goto Github PK

View Code? Open in Web Editor NEW
72.0 1.0 4.0 793 KB

⚛️ An accessible Emoji component for React applications

Home Page: https://npmjs.com/package/a11y-react-emoji

License: MIT License

JavaScript 13.99% TypeScript 86.01%
react emoji a11y accessible component emoji-component

a11y-react-emoji's Introduction

👋 Hey, my name is SeanMcP. I'm interested in using technology to help others, especially in the field of education. If you're interested in building education technology, I'd love to connect.

a11y-react-emoji's People

Contributors

arturparkhisenko avatar dependabot[bot] avatar johannchopin avatar seanmcp 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

a11y-react-emoji's Issues

Make `EmojiProps` interface an extension of `HTMLSpanElement`

I believe the EmojiProps interface should extend the HTMLSpanElement type. That way, additional <span> attributes can be directly passed as props to the Emoji component without raising type errors in TypeScript.

Recommendation:

interface EmojiProps extends React.HTMLAttributes<HTMLSpanElement> {
  label?: string;
  symbol: string;
}

Safely permits usage such as:

<Emoji label="dog" symbol="🐕" className="className" />

Use `undefined` instead of `null` for `aria-label` and `aria-hidden` attributes

When no label prop is specified, the type of aria-label should be undefined instead of null. Same goes for aria-hidden when a label is passed. This aligns with the official React type definitions for both attributes.

Type of aria-label:

(JSX attribute) React.AriaAttributes['aria-label']?: string | undefined

Type of aria-hidden:

(JSX attribute) React.AriaAttributes['aria-hidden']?: boolean | "true" | "false" | undefined

Increased overall bundle.js by 4.4MB

Ouch. Why is that? It seems like this lib should just be generating the correct html, like <span aria-label="positive" role="img">😁</span>?

[Discussion] Accept children prop for emoji

The current API for Emoji requires you pass the emoji string to a symbol prop. This is fine and doesn't need changing.

But what about also accepting the emoji passed as children? The new API would work like this:

<Emoji label="a buzzing bee">🐝</Emoji>

I think children is what the user would expect. The tradeoff is that we would need to handle the scenario where both symbol and children are passed. Who would win in that instance? Or should an error be thrown?

Add a changelog

I like the format from "Keep a Changelog", but I'm open to other suggestions.

Questions to consider:

  • Should this go back and document each previous version?

Update peer dependencies

Will the pending release of React 17, the React peer dependencies should be updated. I think >=16 should world, but it's worth testing out.

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.