Git Product home page Git Product logo

ariakit's Introduction

Ariakit

Toolkit for building accessible web apps with React.
Explore website »



Installation

npm:

npm i @ariakit/react

pnpm:

pnpm add @ariakit/react

Yarn:

yarn add @ariakit/react

Usage

import { useState } from "react";
import { createRoot } from "react-dom/client";
import { Button, Dialog, DialogHeading } from "@ariakit/react";

function App() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Open dialog</Button>
      <Dialog open={open} onClose={() => setOpen(false)}>
        <DialogHeading>Ariakit</DialogHeading>
        <p>Welcome to Ariakit!</p>
      </Dialog>
    </>
  );
}

createRoot(document.getElementById("root")).render(<App />);

Attribution

Browser testing provided by

Contributing

Follow the instructions on the contributing guide.

ariakit's People

Contributors

alexmunoz avatar amogower avatar andarist avatar anuraghazra avatar cloud-walker avatar david-szabo97 avatar dependabot-preview[bot] avatar dependabot[bot] avatar diegohaz avatar ewgenius avatar folz avatar georgekaran avatar github-actions[bot] avatar gracehaz avatar guria avatar joaovitorzv avatar jxom avatar jyash97 avatar k-sav avatar leonardoelias avatar matheus1lva avatar navin-moorthy avatar renatorib avatar renovate[bot] avatar saideepesh000 avatar sarayourfriend avatar scasarotto avatar tcodes0 avatar tom-sherman avatar ubbe-xyz 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  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  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

ariakit's Issues

State enhancers: use render props instead of hocs

import { Hidden } from 'reas'

const MyComponent = () => (
  <Popover.State visible>
    {popover => (
      <Block relative>
        <Button as={Popover.Toggle} {...popover}>Toggle</Button>
        <Popover {...popover}>Popover</Popover>
      </Block>
    )}
  </Popover.State>
)

Comparison with Rebass and others

Hello.
I love styled components, and use mainly my components and sometimes Rebass.
I think an article or something to talk about reas in comparison with Rebass can be usefull.

Thank you for the work on reas !

Make it easier to "fade" Hidden component

Currently, if we want to "fade" or apply another transitions to Hidden and derivate components, we have to do this:

const MyHidden = Hidden.extend`
  display: block !important;
  opacity: 0;
  ${props => props.visible && "opacity: 1"};
`;

We need a nicer way to do that, without having to put that !important.

<Future />

Status

  • Move to @reakit organization.
  • Change the package name to reakit.
  • Add a deprecate warning on reas package.
  • Launch new website.

Branch: reakit


I'm really impressed how this project, which started as something highly experimental, has evolved so much. And this is certainly due to the fact that so many people have believed on it, either collaborating directly or just testing it on their projects.

This project is one of the reasons I quit my job a few months ago. Improving it is my highest priority right now.

I'm opening this issue to tell you guys what I'm planning for Reas in the near future, to say thank you for collaborating on this project, and to invite you to participate in what's to come.

@Thomazella @Andarist @jyash97 @wordofchristian @joao-alberto @Thebigbignooby @boywithsilverwings @mgmgpyaesonewin @menor @nathanforce

ReaKit



logo


When I first designed Reas, its only focus was composability. as was the main method responsible for ensuring high composability, and every component was built around it. So, the name of the library was an obvious combination of "React" and "as".

Let me give you a brief example of what I mean by composability. Let's create some styled components:

import { styled, Base, Button as BaseButton } from "reakit";

const Button = styled(BaseButton)`
  text-transform: uppercase;
  font-weight: 600;
`;

const ButtonRounded = styled(Button)`
  border-radius: 1.25em;
  padding: 0 1.375em;
`;

const ButtonPrimary = styled(Button)`
  background-color: #fc4577;
  border: none;
  color: white;
`;

Now, we can render each one separately:

<Button>Button</Button>

button

<ButtonRounded>Rounded</ButtonRounded>

button

<ButtonPrimary>Primary</ButtonPrimary>

button

Finally, we can leverage composability and combine them:

<ButtonPrimary as={ButtonRounded}>Primary + Rounded</ButtonPrimary>

button

As the project evolved, it became more ambitious. Not only it needed to be composable, but also accessible, and a focus on interactivity was emerging with Containers. It turned out that calling it a "Toolkit" was more appropriate.

And, as you have noticed, I like the obvious:

React + Toolkit = ReaKit

Keeping the tradition of #40, I also don't know how to pronounce it. 😆

Changing the repository name should be seamless. Commit history and everything will be kept. GitHub will automatically redirect diegohaz/reas to diegohaz/reakit and the latter to reakit/reakit.

Migrating to https://www.npmjs.com/package/reakit should be as easy as just replacing all instances of reas to reakit or creating an alias.

Thanks to @brunomacf and @marco-souza from @nosebit for the npm package name.

The new website is being built in the reakit branch and should be done by the next few weeks. Here are some screenshots of it:

desktop website mobile website

The work on master will continue as normal during this time. Nothing will change.

If you like what you read and would like to follow or contribute to this future, join us on https://reakit.slack.com (message me your email address and I'll send you an invite).

Thank you, guys.

Input in Docs sidebar links to Field

Field renders and input with id="input" which leaves two html elements with the same id on the page. The anchor chooses the first one, so it scrolls to Field.

Add prettier

prettier, eslint-config-prettier, eslint-plugin-prettier

Add context state enhancers

I know very few about the new React Context API. But I wonder if we can make something like withStepContext, with the same interface as withStepState, but providing global state. It would be an alternative to withStepReducer (planned on #8):

import React from 'react'
import { Step, withStepState, withStepContext, withStepReducer } from 'reas'

const MySteps = ({ step }) => (
  <div>
    <Step step="foo" {...step}>Foo</Step>
    <Step step="bar" {...step}>Foo</Step>
    <Step step="baz" {...step}>Foo</Step>
  </div>
)

// today
export default withStepState(MySteps)
// or maybe
export default withStepContext(MySteps)
// or maybe
export default withStepReducer(MySteps)

UPDATE:

Since we've replaced state enhancers HOCs with render props in #47, this is the new way I'm planning to have global state:

import React from 'react'
import { Step } from 'reas'

const MySteps = () => (
  <Step.State global="foo">
    {step => (
      <div>
        <Step step="foo" {...step}>Foo</Step>
        <Step step="bar" {...step}>Foo</Step>
        <Step step="baz" {...step}>Foo</Step>
      </div>
    )}
  </Step.State>
)

Change Popover.Arrow and Tooltip.Arrow position according to parent position

Currently, if we pass a different pos to Tooltip or Popover, we also need to change the pos prop on the Arrow component.

<Tooltip pos="bottom">
  <Tooltip.Arrow pos="top" />
  Tooltip
</Tooltip>

That's kind of annoying. Setting pos="bottom" on Tooltip should automatically and correctly position Tooltip.Arrow.

We can't reliably set props on Arrow from Tooltip. The best option we have, I guess, is to change the styles. Something like this:

import { ifProp } from "styled-tools";
import TooltipArrow from "./TooltipArrow";

const Tooltip = styled(Base)`
  position: absolute;
  ${TooltipArrow} {
    // styles based on Tooltip pos
    ${ifProp({ pos: "bottom" }, /* apply styles for pos top */)}
  }
`;

In order to get Perpendicular styles, we should use getStyle from styled-tools:

import { ifProp, getStyle } from "styled-tools";
import TooltipArrow from "./TooltipArrow";

const Tooltip = styled(Base)`
  position: absolute;
  ${TooltipArrow} {
    ${ifProp({ pos: "bottom" }, getStyle(TooltipArrow, { pos: "top" }))};
  }
`;

Reorganize dist folder

I'm thinking about splitting it into lib, es and umd in the root directory.

Also, we should be able to import components and other modules this way:

import Button from "reakit/Button";
import as from "reakit/as";
// or, at least
import Button from "reakit/lib/Button";
import as from "reakit/lib/as";

Perpendicular: angle instead of reverse

Pronunciation of reas

Yeah, I created this library and gave it a name that I don't even know how to pronounce.

I tend to call it re-as, but it's very hard for me to say as without sounding like ass.

I'm creating this issue to see how people read it and finally learn how to pronounce it correctly.

Hidden unmount

Following #57 and #97, I think we should rename destroy prop to unmount on Hidden.

There are other components setting destroy. A global search and replace should do the job.

I'm opening a separate issue for that because it would be a breaking change. A PR should target the next branch.

EDIT: I'm also thinking about styleProp. Maybe it should be hiddenStyle and visibleStyle with some sane shortcuts:

<Hidden
  hiddenStyle="display"
  hiddenStyle="visibility"
  hiddenStyle="opacity"
  hiddenStyle={{ width: 0 }}
  visibleStyle={{ width: "100%" }}
/>

Add prop types table to components docs

Currently, we are not documenting prop types except those added to examples. That's because react-styleguidist, which uses react-docgen under the hood, can't identify our components due to the way we declare it.

Group List

Hi @diegohaz ,

I just discover Reas an I love the concept to create component like Lego.
The goal of this it's create components with the minimun styles to add, is not it?

I was play with it and I saw the Group component with the button component.
I try the List component with group like this

  <List as={Group} vertical>
      <List.Item>Item 1</List.Item>
      <List.Item>Item 2</List.Item>
      <List.Item>Item 3</List.Item>
      <List.Item>Item 4</List.Item> 
  </List>

); 

I was thinking see the list with border like the group buttons example, but It does'nt work.

You think implemented It or maybe there a a other way to make it?

I know for the moment it's a experimentation but I find the idea really good, I hope you will push the concept far far way.

I believe you work on a new version of the site?
Don't forget add a kind of sandBox for create a community and allow them to show their experimentations / artworks

Theming

import { ThemeProvider } from "reas";

const theme = {
  Button: `
    background-color: red;
  `
}

const App = () => (
  <ThemeProvider theme={theme}>
    ...
  </ThemeProvider>
);

We're already exporting ThemeProvider from styled-components. To make that work, we need to add theme in all components. For example, in Button:

import styled from "styled-components";
import { prop } from "styled-tools";
import Base from "../Base";

const Button = styled(Base)`
  ${prop("theme.Button")}
`;

export default Button;

Blockquote

Instructions:

  1. Fork, clone the repository in your local machine and install dependencies (yarn or npm install);
  2. Run yarn docs or npm run docs and open http://localhost:6060 in your browser;
  3. Duplicate any simple component inside src/components (e.g. Block) naming it Blockquote (generact can help you with that);
  4. Update Blockquote.js to create the component and Blockquote.md to update docs (and to see if everything is working);
  5. Update src/components/index.js to add Blockquote.js to exports.

Automatic changelog

We should use a tool to generate changelogs. It should support "beta" versions like v0.10.0.

Improve docs

Any help with docs would be very welcome.

And, since I'm not a native English speaker, I could have made some mistakes. If you find an error, please do submit a PR with the correction.

Thank you, guys.

<Navigation> is missing

Hi!

First, thanks for such a cool lib!
Unfortunately, I have got this: 'reas' does not contain an export named 'Navigation'. I am using reas NPM package (0.10.2), just checked it - it really does not have such component :(

Layout component

We need a Layout component where we can define Slots where other components can be placed.

I'm thinking in something like this:

import { Layout, Block } from "reas";

const MyLayout = ({ children }) => (
  <Layout>
    <Layout.Slot as="header" name="header" />
    <Layout.Slot as="main" name="main">{children}</Layout.Slot>
    <Layout.Slot as="footer" name="footer" />
  </Layout>
);

const MyComponent = () => (
  <MyLayout>
    <Block as={Layout.Fill} slot="main">Main</Block>
    <Block as={Layout.Fill} slot="footer">Footer</Block>
    <Block as={Layout.Fill} slot="header">Header</Block>
  </MyLayout>
);

Probably, Layout.Fill should use something like React.createPortal.

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.