Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: adobe/react-spectrum
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: react-stately@3.25.0
Choose a base ref
...
head repository: adobe/react-spectrum
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: react-stately@3.26.0
Choose a head ref

Commits on Aug 9, 2023

  1. Move InlineAlert types into RSP (#4890)

    No need for a separate @react-types/package
    devongovett authored Aug 9, 2023
    1
    Copy the full SHA
    cd601ff View commit details
  2. Merge branch 'main' of github.com:adobe/react-spectrum

    # Conflicts:
    #	packages/@react-spectrum/inlinealert/package.json
    #	packages/@react-types/inlinealert/package.json
    devongovett committed Aug 9, 2023
    Copy the full SHA
    5dd5fcd View commit details
  3. 1
    Copy the full SHA
    d4dfe4b View commit details
  4. August 2023 release notes (#4889)

    * release notes
    dannify authored Aug 9, 2023
    2
    Copy the full SHA
    0e35939 View commit details

Commits on Aug 10, 2023

  1. Removing aria-disabled so TalkBack users can open the context dialog (#…

    …4710)
    
    * Removing aria-disabled so TalkBack users can double tap to open the context dialog
    
    * Updating aria-describedby label for unavailable menu items
    LFDanLu authored Aug 10, 2023
    1
    Copy the full SHA
    66f9638 View commit details
  2. RAC + Spectrum + Tailwind example (#4819)

    * initialize example
    
    * add to verdaccio
    
    * typo
    
    * temporarily enable build comment
    
    * temp remove main filter
    
    * add readme
    
    * update config
    
    * add more examples
    
    * improve default focus ring
    
    * simplify examples
    
    * split out into preset
    
    * add font weights
    
    * add letterSpacing and lineHeight
    
    * add transition timings and durations
    
    * improve sentiment example
    
    * improve select box example
    
    * improve select box example
    
    * improve examples
    
    * add sizes
    
    * fix size values
    
    * fix transition values
    
    * update break points
    
    * improve examples
    
    * add dropShadow to preset
    
    * add Theme switcher
    
    * dark mode fixes
    
    * clean up
    
    * fix spacing/sizing
    
    * spacing
    
    * cleanup
    
    * add default blue
    
    * add opacity
    
    * fix theme switcher margin
    
    * add rac plugin
    
    * update sentiment example to style w/ attributes
    
    * add plugin to config
    
    * cleanup attributes in plugin
    
    * cleanup plugin
    
    * add more color variants
    
    * formatting
    
    * update README
    
    * cleanup
    
    * use custom selector for dark mode
    
    * revert CI changes
    
    * cleanup
    reidbarber authored Aug 10, 2023
    1
    Copy the full SHA
    1775ff2 View commit details
  3. Un-revert "fix(#4313): ariaHideOutside/aria-modal-polyfill: use inert…

    … instead of aria-hidden where supported (#4314) #4881 (#4883)
    
    * Revert "Revert "fix(#4313): ariaHideOutside/aria-modal-polyfill: use inert instead of aria-hidden where supported (#4314)" (#4881)"
    
    This reverts commit 8e6cefd.
    
    * useLayoutEffect -> useEffect in usePopover
    reidbarber authored Aug 10, 2023
    1
    Copy the full SHA
    be50125 View commit details

Commits on Aug 15, 2023

  1. [RAC]: Update Tabs navigation for arrow keys (#4821)

    Allow tab item select via all arrow keys regardless of orientation.
    
    Co-authored-by: Daniel Lu <dl1644@gmail.com>
    mariareedstrom and LFDanLu authored Aug 15, 2023
    1
    Copy the full SHA
    c6313b4 View commit details

Commits on Aug 16, 2023

  1. Add support for automated Storybook accessibility testing (#4820)

    * quick convert to csf 3
    
    * cleanup and disabling aria-hidden rule
    
    * adding storybook test runner
    
    * sample failures for test to catch
    
    * Revert "sample failures for test to catch"
    
    This reverts commit 36fa68a.
    
    * experimenting with interaction test
    
    * poking around to try and ignore aria rule for specific selector
    
    * test catching render errors and reuse play functions
    
    * using story axe config instead of manually setting it in main
    
    * fix lint and add keyboard interaction test
    
    * experiementing with jest-axe
    
    * testing interaction panel with simpler component
    
    * update yarn.lock
    
    * comments and cleanup
    
    * removing axe-core stuff
    
    this is a working commit before version bumping storybook interactions, for some reason it is breaking
    
    * disabling some false positives and run against all stories
    
    * fix storyName warning from storybook test runner
    
    * adding partial DnD interactions test
    
    * fixing yarn.lock after rebase
    
    * fixing package.json from rebase
    
    * update and cleanup tests + update to data test ids
    
    * fix/ignore various story only aXe issues (Card,Dialog, Landmark, DnD)
    
    some are fixed by adding ids/labels, other are ignored because they are story only tests cases and not part of the actual component accessibility
    
    * fix/ignore various story only aXe issues (ListBox, NumberField, Table, Toast, RAC)
    
    * fix/ignore various story only aXe issues (FocusScope, List, Checkbox, Meter, SideNav
    
    * fixing the rest of the failing false positive tests
    
    * fix lint
    LFDanLu authored Aug 16, 2023
    1
    Copy the full SHA
    09a258f View commit details

Commits on Aug 18, 2023

  1. 1
    Copy the full SHA
    0607fd9 View commit details
  2. Migrate all RAC render props to data attributes (#4891)

    * added corresponding data-attributes
    
    * update docs and selectors to data atrributes
    
    * fix typos
    
    * update example css and add some missing data attributes
    
    * reword styling, update data attributes
    
    * update css pseudo classes to data attributes
    
    * convert other html attributes to data attributes
    
    * update css in docs
    
    * revert meter data attribute
    
    * fix tests
    
    * fix data-sort-direction in table
    
    * revert spacing changes to meter
    
    * update data attributes, fix css
    yihuiliao authored Aug 18, 2023
    1
    Copy the full SHA
    1ef9091 View commit details
  3. Testing documentation and util RFC (#4835)

    * rfc rough draft
    
    * adding some more links
    LFDanLu authored Aug 18, 2023
    1
    Copy the full SHA
    1a41685 View commit details
  4. Revert fix(#4313): ariaHideOutside/aria-modal-polyfill: use inert ins…

    …tead of aria-hidden (#4942)
    
    * Revert "Un-revert "fix(#4313): ariaHideOutside/aria-modal-polyfill: use inert instead of aria-hidden where supported (#4314) #4881 (#4883)"
    
    This reverts commit be50125.
    
    * Empty-Commit
    LFDanLu authored Aug 18, 2023
    1
    Copy the full SHA
    8987f92 View commit details

Commits on Aug 22, 2023

  1. 1
    Copy the full SHA
    4ce4d1d View commit details

Commits on Aug 23, 2023

  1. 1
    Copy the full SHA
    dc61485 View commit details
  2. Adds check to detect Android pointer type as touch (#4940)

    * add additonal check to detect virtual event
    
    * fix logical operator
    
    * add unit test
    
    * remove console log and update unit test
    
    * remove extra spacing, fix test
    
    * remove only from test
    
    * fix teset
    yihuiliao authored Aug 23, 2023
    1
    Copy the full SHA
    9b2c2e1 View commit details
  3. 1
    Copy the full SHA
    145c903 View commit details

Commits on Aug 24, 2023

  1. 1
    Copy the full SHA
    e35ab0d View commit details
  2. RAC: add Tailwind plugin for RAC states (#4933)

    * add tailwind plugin for RAC states
    
    * add docs
    
    * add option for prefix
    
    * update docs to mention prefix option
    
    * update to use data-rac attribute
    
    * change focused->focus and hovered->hover
    
    * update example app to use plugin
    
    * fix selector
    
    * fix test
    
    * add native element to test app
    
    * temp run verdaccio build
    
    * temp run verdaccio build
    
    * revert verdaccio
    
    * typo
    reidbarber authored Aug 24, 2023
    1
    Copy the full SHA
    5f69479 View commit details
  3. Hidden text field is focusable and editable with Select with isDisabl…

    …ed=true (#4943)
    
    * pass isDisabled prop to HiddenSelect
    
    * Add test
    
    ---------
    
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    pr7prashant and snowystinger authored Aug 24, 2023
    1
    Copy the full SHA
    13a2792 View commit details
  4. Remove unused code (#4886)

    * Remove dead test
    marob authored Aug 24, 2023
    1
    Copy the full SHA
    9669c44 View commit details

Commits on Aug 25, 2023

  1. Keep focus on last pressed column header through loading state (#4249)

    * Keep focus on last pressed column header through loading state
    
    * fix lint
    
    * add comment
    
    * add manager focused condition
    
    * no tabbing to column headers when table is empty
    
    * cleanup focus if table becomes empty
    
    * fix lint
    
    * fix focus target on blur
    
    * update story to trigger empty state on 2nd press of table column header
    
    * simplify
    
    * fix tests
    
    * fix issue where items cutoff focus ring on entire collection
    
    * Add test
    
    * revert logic to focus first item
    
    * fix test
    
    * fix box shadow cutoff
    
    ---------
    
    Co-authored-by: Daniel Lu <dl1644@gmail.com>
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    Co-authored-by: Danni <darobins@adobe.com>
    4 people authored Aug 25, 2023
    1
    Copy the full SHA
    3b390fd View commit details

Commits on Aug 26, 2023

  1. Fix Unavailable Menu Item's Popover positioning (#4917)

    * show overflow of popover
    
    * detect if scroll is prevented in position calc
    
    * add docs example to see fix
    
    * only overflow when submenus are shown
    
    * Fix menu clipping corners
    
    * only make overflow visible on menus
    
    * update type
    
    * revert docs change
    
    ---------
    
    Co-authored-by: Rob Snow <rsnow@adobe.com>
    reidbarber and snowystinger authored Aug 26, 2023
    1
    Copy the full SHA
    8d367e0 View commit details

Commits on Aug 28, 2023

  1. 1
    Copy the full SHA
    2f32c05 View commit details
  2. 1
    Copy the full SHA
    e02d205 View commit details

Commits on Aug 29, 2023

  1. Add isPending prop to Button component which triggers a spinner. (#…

    …4900)
    
    * Add `isPending` prop to `Button` component which triggers a spinner.
    
    * Fix lint errors
    
    * Added test
    
    * Only import the necessary package from react-aria
    
    * Remove unnecessary timeout ref.
    
    * Remove pointer events override
    
    * Update test
    
    * Add hook to filter out interactions during pending
    
    * Added cases to story
    
    * update pending story
    
    * whitespace fix
    
    * update pending story
    
    * update pending story
    
    * remove spacing override on loader icon
    
    * make anchor button-like things disabled when pending
    
    * update button docs
    
    * Simplify button story
    
    * Update isPending tests
    
    * Apply progressCircle overBackground to static color buttons
    
    * Style display with visibility instead of opacity
    
    * Improve vertical centering of spinner
    
    * Remove extra dependency
    
    * Added more disabled props while pending
    
    * Update Pending docs
    
    * Rename function so it doesn't sound like a hook
    
    * Defense
    
    * Use proper naming convention
    
    * Simplify story naming
    
    * Update test
    
    * Add aria-live to pending button when pending
    
    * Add check that spinner isn't in document
    
    * Remove cruft
    
    * Move progressCircle props to component
    
    * Fix typos
    
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    
    * change story action
    
    * fix typo
    
    * Add additional info to isPending type comment
    
    * Fix lint problem
    
    * Remove focus and blur from blocked events
    
    * prefix isPending with UNSTABLE
    
    * remove doc changes for now
    
    * Revert unintended change
    
    ---------
    
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    iamwillpowell and snowystinger authored Aug 29, 2023
    1
    Copy the full SHA
    53ddbb6 View commit details
  2. Rsp dropzone (#4757)

    * initialize dropzone
    
    * brainstorm
    
    * cleanup dropzone
    
    * merge
    
    * update stories with actions
    
    * messages
    
    * use rac dropzone
    
    * input stuff
    
    * add css, change dropzone ref
    
    * set isFilled
    
    * add css, trying stuff in dropzone
    
    * add unfilled/filled state
    
    * added bannerMessage and isFilled prop, update stories
    
    * clean up stories
    
    * added a test
    
    * updated css, exported Draggable, clean up package.json
    
    * add imperative handle - tbd whether it is kept
    
    * cleanup
    
    * fix react-aria-component dependency
    
    * create new css folder for dnd stories
    
    * add text component to story
    
    * add spacing, add tests, whcm css
    
    * clean up rac dropzone
    
    * add more tests
    
    * fix typo
    
    * fix stories, fix typo in css, remove focus styling
    
    * added jsdoc comments, new story, export types
    
    * add css to new story, change examples to buttons, minor css changes
    
    * fix linting
    
    * fix typo
    
    * remove imperative handler from dropzone
    
    * fix tests
    
    * fix typo
    
    * update css to match new style for banner, update css for whcm
    
    * fix typo, add draggable image to story
    
    * update text color to meet color contrast
    
    * fix indentation
    
    * fix indentation
    
    * update package
    
    * update css and tests, styled filled state for stories, message announces on VO
    
    * update useId import
    
    * small code review changes
    
    * fix HCM
    
    * fix lint
    
    * add missing filter dom props to filetrigger
    
    * further hcm fixes
    
    * update stories with text component
    
    ---------
    
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    Co-authored-by: Daniel Lu <dl1644@gmail.com>
    3 people authored Aug 29, 2023
    1
    Copy the full SHA
    6f39866 View commit details
  3. Fix RadioGroup lost roving tab index (#4985)

    * Fix RadioGroup lost roving tab index
    snowystinger authored Aug 29, 2023
    1
    Copy the full SHA
    a633130 View commit details

Commits on Aug 30, 2023

  1. Add translations to RSP Dropzone (#4989)

    * Add translations to RSP Dropzone
    
    * update name for clarity
    yihuiliao authored Aug 30, 2023
    1
    Copy the full SHA
    d4d21a7 View commit details
  2. 1
    Copy the full SHA
    64e3590 View commit details
  3. 1
    Copy the full SHA
    1c14740 View commit details
  4. Add a link to storybook (#4996)

    * Add a link to storybook
    
    * Swap single quote for backtick
    iamwillpowell authored Aug 30, 2023
    1
    Copy the full SHA
    3276459 View commit details

Commits on Aug 31, 2023

  1. [RAC] Table - allow passing render prop to Cell (#4995)

    * Table - allow passing render prop
    
    * Fix forwardRef type
    
    ---------
    
    Co-authored-by: Devon Govett <devongovett@gmail.com>
    Co-authored-by: Reid Barber <reid@reidbarber.com>
    3 people authored Aug 31, 2023
    1
    Copy the full SHA
    ea35ed0 View commit details
  2. Adding Unavailable Menu Item docs (#4763)

    * Adding Unavailable Menu Item docs
    
    * removing similar text
    
    * rewording two concepts
    
    * fix spelling mistakes
    
    Co-authored-by: Michael Jordan <mijordan@adobe.com>
    
    * Adding more explanation in a couple cases
    
    * using the Unavailable Items as the name
    
    * switching the order of two paragraphs
    
    * update docs and types
    
    * fix props table
    
    * update types and docs table
    
    * address review comments
    
    ---------
    
    Co-authored-by: Michael Jordan <mijordan@adobe.com>
    Co-authored-by: Reid Barber <reid@reidbarber.com>
    Co-authored-by: Daniel Lu <dl1644@gmail.com>
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    5 people authored Aug 31, 2023
    1
    Copy the full SHA
    30f1728 View commit details
  3. 1
    Copy the full SHA
    e7b9c16 View commit details

Commits on Sep 1, 2023

  1. 1
    Copy the full SHA
    9255da6 View commit details
  2. 1
    Copy the full SHA
    67c19ff View commit details
  3. Fix missing peerDependency on react-dom (#5002)

    * Fix missing peerDependency on react-dom
    
    Fixes #4934
    
    * add a package lint for peer deps
    
    ---------
    
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    wojtekmaj and snowystinger authored Sep 1, 2023
    1
    Copy the full SHA
    7fe63ab View commit details
  4. 1
    Copy the full SHA
    3b92155 View commit details

Commits on Sep 2, 2023

  1. Fix buttongroup infinite update loop (#5010)

    * Fix buttongroup infinite update loop
    snowystinger authored Sep 2, 2023
    1
    Copy the full SHA
    2600c96 View commit details

Commits on Sep 5, 2023

  1. Make all submenus close upon user interact outside (#4988)

    * Make all submenus close upon user interact outside
    
    * add test
    
    * refactor to close on underlay press
    
    * turns out we dont need the ref
    
    * restrict to spectrum for now
    
    adding the logic to useOverlay brings up the possibility where a user could have a dismissible overlay open a non dismissible overlay but the absense of a underlay for the non dismissible overlay would then make the click on the dismissible overlay's underlay close both overlays which is different behavior from before. Isolating this change to spectrum for our submenu case until we implement something like focusscope tree to detect clicks outside the tree of menus
    LFDanLu authored Sep 5, 2023
    1
    Copy the full SHA
    07260d1 View commit details
  2. 1
    Copy the full SHA
    e89b9bc View commit details
  3. 1
    Copy the full SHA
    061007a View commit details
  4. 1
    Copy the full SHA
    cea5511 View commit details

Commits on Sep 6, 2023

  1. fix: useSelect trigger label (#4949)

    * fix: useSelect trigger label
    
    * fix lint and tests
    
    * fix: fixed label merge logic
    
    * fix tests
    
    ---------
    
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    Co-authored-by: Daniel Lu <dl1644@gmail.com>
    3 people authored Sep 6, 2023
    1
    Copy the full SHA
    50b1e19 View commit details
  2. 1
    Copy the full SHA
    2a98c9f View commit details
  3. 1
    Copy the full SHA
    4e51283 View commit details
  4. Move ContextualHelpTrigger docs to Menu (#5017)

    * Move ContextualHelpTrigger docs to Menu
    
    * import Keyboard
    
    * forgot to save
    
    ---------
    
    Co-authored-by: Robert Snow <rsnow@adobe.com>
    LFDanLu and snowystinger authored Sep 6, 2023
    1
    Copy the full SHA
    a39ac2f View commit details
  5. Remove erroneous accessibility color contrast ignore rule (#5029)

    investigated, turns out it is a legitimate color contrast problem
    LFDanLu authored Sep 6, 2023
    1
    Copy the full SHA
    c961c55 View commit details
  6. 1
    Copy the full SHA
    b0c7300 View commit details
Showing 636 changed files with 20,285 additions and 8,050 deletions.
4 changes: 3 additions & 1 deletion .circleci/comment.js
Original file line number Diff line number Diff line change
@@ -51,11 +51,13 @@ async function run() {
[CRA Test App](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/build/index.html)
[NextJS Test App](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/next/index.html)
[RAC Tailwind Example](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/rac-tailwind/index.html)
[RAC Spectrum + Tailwind Example](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/rac-tailwind/index.html)
[CRA Test App Size](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/build-stats.txt)
[NextJS App Size](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/next-build-stats.txt)
[Publish stats](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/publish.json)
[Size diff since last release](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/publish-stats/size-diff.txt)
[Docs](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/docs/index.html)`
[Docs](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/verdaccio/docs/index.html)
[Storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html)`
});
}
} catch (error) {
39 changes: 39 additions & 0 deletions .storybook/test-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const {configureAxe, checkA11y, injectAxe} = require('axe-playwright');
const {getStoryContext} = require('@storybook/test-runner');


/*
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental
* to learn more about the test-runner hooks API.
*/
module.exports = {
async preRender(page) {
await injectAxe(page);
},
async postRender(page, context) {
// Grab accessibility settings from the story itself
const storyContext = await getStoryContext(page, context);
if (storyContext.parameters?.a11y?.disable) {
return;
}

await configureAxe(page, {
// TODO: Ideally would have a selector target for the storybook's sb main body element
rules: [
{
id: 'aria-hidden-focus',
selector: 'body *:not([data-a11y-ignore="aria-hidden-focus"])',
},
...(storyContext.parameters?.a11y?.config?.rules ?? [])
]
});

await checkA11y(page, '#root', {
detailedReport: true,
detailedReportOptions: {
html: true,
},
axeOptions: storyContext.parameters?.a11y?.options,
});
},
};
7 changes: 7 additions & 0 deletions examples/rac-spectrum-tailwind/.parcelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@parcel/config-default",
"resolvers": ["@parcel/resolver-glob", "..."],
"transformers": {
"../../packages/*/*/intl/*.json": ["parcel-transformer-intl"]
}
}
5 changes: 5 additions & 0 deletions examples/rac-spectrum-tailwind/.postcssrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": {
"tailwindcss": {}
}
}
24 changes: 24 additions & 0 deletions examples/rac-spectrum-tailwind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# React Aria Components + Spectrum + Tailwind CSS

A Tailwind CSS template for creating React Aria Components using common Spectrum styles.

## Overview

### Includes

- `Theme`: a preset that includes Spectrum values for colors, scale and more
- `Plugin`: for easier styling based on React Aria Component's selectors for states

### When to use this

- You need a component that matches an ARIA pattern, but doesn't exist in React Spectrum
- You are prototyping a component that might be a good fit for a future addition to React Spectrum, but isn't available yet

### When not to use this

- There is an existing React Spectrum component that matches your needs
- You are trying to override Spectrum guidelines or create a slight variation of an existing React Spectrum component

### Note

This is not a library you can install and consume, but rather a template that you can copy into your own project and maintain yourself. Keep in mind that you are still responsible for ensuring the experiences you create are accessible and meet Spectrum guidelines.
25 changes: 25 additions & 0 deletions examples/rac-spectrum-tailwind/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "rac-spectrum-tailwind-example",
"private": true,
"scripts": {
"start": "parcel src/index.html",
"build": "parcel build src/index.html",
"install-17": "yarn add -W react@^17 react-dom@^17"
},
"dependencies": {
"@adobe/react-spectrum": "^3.28.0",
"@spectrum-icons/illustrations": "^3.6.3",
"@spectrum-icons/workflow": "^4.2.2",
"parcel": "^2.9.1",
"postcss": "^8.2.1",
"react": "^18.2.0",
"react-aria-components": "^1.0.0-alpha.4",
"react-dom": "^18.2.0",
"react-stately": "^3.23.0",
"tailwindcss": "^3.3.0",
"tailwindcss-animate": "^1.0.5"
},
"devDependencies": {
"process": "^0.11.10"
}
}
119 changes: 119 additions & 0 deletions examples/rac-spectrum-tailwind/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { useState } from "react";
import { defaultTheme, Provider } from "@adobe/react-spectrum";
import { Label, Radio, RadioGroup } from "react-aria-components";
import User from "@spectrum-icons/workflow/User";
import UserGroup from "@spectrum-icons/workflow/UserGroup";
import Building from "@spectrum-icons/workflow/Building";
import CheckmarkCircle from "@spectrum-icons/workflow/CheckmarkCircle";
import ThemeSwitcher from "./ThemeSwitcher";

export function App() {
let [colorScheme, setColorScheme] = useState(undefined);

return (
<Provider theme={defaultTheme} colorScheme={colorScheme}>
<ThemeSwitcher setColorScheme={setColorScheme} />
<div className="grid justify-center grid-cols-1 gap-160 auto-rows-fr">
<SelectBoxExample />
<SentimentRatingGroup />
<div className="flex justify-center">
<div className="flex flex-col max-w-sm">
<label for="test-input">Native input</label>
<input id="test-input" className="border focus:bg-gray-200 focus:outline-none focus:border-blue-600 hover:border-blue-300" />
<p>For the purpose of ensuring Tailwind's default selectors still work for non-RAC elements when using the plugin.</p>
</div>
</div>
</div>
</Provider>
);
}

function SelectBoxExample() {
return (
<RadioGroup
data-rac
className="flex flex-col space-y-2 text-center"
defaultValue="Team"
>
<Label className="text-xl font-semibold">Select Boxes</Label>
<div className="flex justify-center">
<SelectBox
name="Individual"
icon={<User size="XL" />}
description="For 1 person"
/>
<SelectBox
name="Team"
icon={<UserGroup size="XL" />}
description="For teams of 9 or less"
/>
<SelectBox
name="Enterprise"
icon={<Building size="XL" />}
description="For of 10 or more"
/>
</div>
</RadioGroup>
);
}

function SelectBox({ name, icon, description }) {
return (
<Radio
data-rac
value={name}
className={({ isFocusVisible, isSelected, isPressed }) => `
flex justify-center p-160 m-160 h-2000 w-2000 focus:outline-none border rounded
${isFocusVisible ? "ring-half ring-offset-0" : ""}
${isSelected ? "bg-accent-100 border-accent-700" : ""}
${isPressed && !isSelected ? "bg-gray-200" : ""}
${!isSelected && !isPressed ? "bg-white dark:bg-black" : ""}
`}
>
{({ isSelected }) => (
<div className="relative flex flex-col items-center justify-center w-full h-full gap-150">
{isSelected && (
<div className="absolute top-0 left-0 text-accent-800 -mt-125 -ml-75">
<CheckmarkCircle size="S" />
</div>
)}
{icon && <div className="text-gray-500">{icon}</div>}
<div>
<div className={`font-semibold`}>{name}</div>
{description && <div className="text-sm">{description}</div>}
</div>
</div>
)}
</Radio>
);
}

function SentimentRatingGroup() {
let ratings = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
return (
<RadioGroup className="flex flex-col m-auto space-y-10 text-center">
<Label className="text-xl font-semibold">Sentiment Rating</Label>
<div className="flex justify-between">
<span>Least Likely</span>
<span>Most Likely</span>
</div>
<div className="flex justify-evenly">
{ratings.map((rating) => (
<SentimentRating key={rating} rating={rating} />
))}
</div>
</RadioGroup>
);
}

function SentimentRating({ rating }) {
return (
<Radio
data-rac
value={rating}
className="flex items-center justify-center bg-white border rounded-full p-160 m-75 h-200 w-200 focus:outline-none focus-visible:ring dark:bg-black selected:bg-accent-800 dark:selected:bg-accent-800 selected:border-accent-800 selected:text-white pressed:bg-gray-200 dark:pressed:bg-gray-200 hover:border-gray-300"
>
{rating}
</Radio>
);
}
21 changes: 21 additions & 0 deletions examples/rac-spectrum-tailwind/src/ThemeSwitcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useProvider, ActionButton } from "@adobe/react-spectrum";
import Moon from "@spectrum-icons/workflow/Moon";
import Light from "@spectrum-icons/workflow/Light";

export default function ThemeSwitcher({ setColorScheme }) {
let { colorScheme } = useProvider();
let label =
colorScheme === "dark" ? "Switch to light theme" : "Switch to dark theme";
let otherScheme = colorScheme === "light" ? "dark" : "light";

return (
<div className="float-right m-50">
<ActionButton
aria-label={label}
onPress={() => setColorScheme(otherScheme)}
>
{colorScheme === "dark" ? <Light /> : <Moon />}
</ActionButton>
</div>
);
}
13 changes: 13 additions & 0 deletions examples/rac-spectrum-tailwind/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>React Aria Components + Spectrum + Tailwind</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="style.css">
</head>
<body class="bg-white text-gray-800">
<div id="root"></div>
<script type="module" src="index.js"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions examples/rac-spectrum-tailwind/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createRoot } from "react-dom/client";
import { App } from './App';

let root = createRoot(document.getElementById('root'));
root.render(<App />);

Loading