GithubHelp home page GithubHelp logo

eknowles / react-reel Goto Github PK

View Code? Open in Web Editor NEW
69.0 1.0 9.0 1.61 MB

Animate any number like a slot machine. *Update* As used on Reddit! Add some flare to your metrics.

Home Page: https://eknowles.github.io/react-reel/

HTML 3.74% JavaScript 92.76% CSS 3.50%
react animation themeable

react-reel's Introduction

react-reel

Animate anything like a slot machine

NPM JavaScript Style Guide GitHub stars GitHub issues

Example

Features

  • Fully themeable
  • Highly performant, runs at 60fps
  • Animates anything you want!

Install

$ npm install --save react-reel

or

$ yarn add react-reel

Basic Usage

import React, { Component } from 'react'

import Reel from 'react-reel'

const Example = () => <Reel text="$34.42" />;

Props

  static propTypes = {
    /** @type {string} text */
    text: PropTypes.string.isRequired,
    /** @type {number} [1000] duration - animation duration in milliseconds */
    duration: PropTypes.number,
    /** @type {number} DELAY - delay between each sibling animation */
    delay: PropTypes.number,
    /** @type {{reel: string, group: string, number: string}} theme - react-themeable */
    theme: PropTypes.any,
  };

  static defaultProps = {
    duration: 700,
    delay: 85,
    theme: defaultTheme,
  };

Theme

This uses react-themeable

react-reel comes with no styles.

It uses react-themeable that allows you to style your component using CSS Modules, Radium, Aphrodite, JSS, Inline styles, and global CSS.

For example, to style using CSS Modules, do:

.group {
  transition-delay: 0ms;
  transition-timing-function: ease-in-out;
  transform: translate(0, 0);
}

.group .number {
  height: 1em;
}

.reel {
  height: 1em;
  display: flex;
  align-items: flex-end;
  overflow-y: hidden;

  /** CUSTOMISE BELOW */
  font-size: 45px;
  font-weight: 300;
  color: #E2AB5B;
  border-bottom: 1px solid #0492BD;
  line-height: 0.95em; /* adjusted for Lato font */
}
import theme from 'theme.css';
<Reel theme={theme} ... />

When not specified, theme defaults to:

{
  reel:   'react-reel__reel',
  group:  'react-reel__group',
  number: 'react-reel__number',
}

License

MIT © eknowles

react-reel's People

Contributors

eknowles 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

Watchers

 avatar

react-reel's Issues

Toggling styles is not at once

Great Project!

Please see problem 1 in this codepen:
When toggling the design of the Reel, the change is not immediate.
Is there a way to do it instantly (or faster)?

Example code not working

Hey, this seems really great and I'd love to use it but it seems as though the example in the readme you have (or anything I've tried for that matter) is not working.

It looks like things just end up vertically stacked and overlapping... Here's an example I put together in code sandbox running the latest version of React. I've also tried rolling back as far as version 16.3 (which was out well before your latest commit)

https://codesandbox.io/s/72z31m88wx

Please do let me know if I am doing something wrong though and clumsily overlooking something.

image

Number alignment

Hey,
Numbers in the reel sometimes do not align well. Is this a known bug or should I reconsider changing its CSS? See the ss below.

Screen Shot 2022-11-04 at 9 47 32 AM

CSS
const reelTheme = { group: { transitionDelay: '0ms', transitionTimingFunction: 'ease-in-out', transform: 'translate(0, 0)', height: '1em' }, reel: { height: '1em', display: 'flex', alignItems: 'flex-end', justifyContent: 'flex-start', letterSpacing: '-1px', overflowY: 'hidden', fontSize: '0.875em', lineHeight: '1em' }, number: { height: '1em' } };

Invisible digits are not hidden from screen readers

This makes webpages using react reel virtually unusable by screen reader users because they have to navigate through all 9 hidden digits for each column of text output by react-reel. For numbers that are 2 or more digits large, this means dozens of times to press the arrow key just to see what comes next on the webpage. If you look at the screenshot, you can see that the area of the digits is larger because it includes all 10 digits.

I'm going to play around with it but something as simple as putting role="presentation" on all react-reel__group divs and their descendants should be enough. That way the parent's aria-label is read and nothing else.

I tested this on an M1 Macbook Pro running Ventura 13.3.1, with Firefox 112.0.

Screenshot 2023-04-14 at 4 33 54 PM

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.