Giter VIP home page Giter VIP logo

pattern-library's Introduction


⚠️ DEPRECATION NOTICE ⚠️

This repo is deprecated. Please go to https://github.com/dequelabs/cauldron

Pattern Library CircleCI

Installation

NPM

$ npm install deque-pattern-library

Bower

$ bower install deque-pattern-library

CDN

Thanks to unpkg, you can link directly to deque pattern library files.

<link rel="stylesheet" href="https://unpkg.com/deque-pattern-library/dist/css/pattern-library.min.css" />
<!-- or -->
<link rel="stylesheet" href="https://unpkg.com/deque-pattern-library/dist/css/pattern-library.css" />
<script src="https://unpkg.com/deque-pattern-library/dist/js/pattern-library.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/deque-pattern-library/dist/js/pattern-library.js"></script>

Fonts

Including font awesome (v4)

The pattern library relies on font awesome meaning including it is required.

CDN

You can include it using a CDN (see font awesome getting started docs)

npm

$ npm install font-awesome --save

Including Roboto

The patterns look best when the roboto font is available.

CDN

You can include it using a CDN, like so:

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700">

npm

install it:

$ npm install typeface-roboto --save

include it (in your entry-point):

import 'typeface-roboto';

Usage

Just drop the css and js into your page:

<html>
  <head>
    ...
    <link rel="stylesheet" href="./node_modules/deque-pattern-library/dist/css/pattern-library.min.css" />
  </head>
  <body>
    ...
    <script src="./node_modules/deque-pattern-library/dist/js/pattern-library.min.js"></script>
  </body>
</html>

What is included?

  • css
    • pattern-library.css
    • pattern-library.min.css
  • js
    • pattern-library.js
    • pattern-library.min.js
  • less
    • variables.less: All of the pattern library's colors and mixins

Getting started

Please refer to the wiki

Adding new components/composites

All additions must be approved by our UX team so before working on anything, please create an Issue including a detailed description on the requested pattern and several use cases for it.

Development

  • npm install
  • npm run build or for development - npm run dev which will rebuild when files are changed

NOTE: if a new component or composite is added, remember to create a quick wiki entry explaining what is absolutely necessary in using this widget.

Testing

Testing is done using mochify along with the 'chai' assertion library (assert.isFalse(!!0)). The test/ directory structure matches the lib/ directory. This means that if you're testing lib/components/foo/index.js, you would create a test in test/components/foo/index.js. See the test/ directory for examples. The tests are browserified and transpiled before running in the phantomjs headless browser so you can require / import stuff and use ES6 syntax in the tests.

$ npm test

or to have a watcher re-run tests every time you add a new test:

$ npm run test:dev

Debugging

The pattern library uses the debug module. To turn all debugging on, execute: localStorage.debug = 'dqpl:*' and refresh the page. The directory structure of lib is used as the debug naming convention. For example, to specifically debug the "selects" component, execute: localStorage.debug = 'dqpl:components:selects'.

pattern-library's People

Contributors

autosponge avatar iandotkelly avatar mariolo1985 avatar roman-bytes avatar schne324 avatar scurker avatar stephenmathieson avatar svinkle 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

pattern-library's Issues

Required, Required

This reference contains two patterns for required form fields. However, this example in the pattern library uses a hybrid:

<div class="dqpl-field-wrap">
      <label class="dqpl-label dqpl-required" for="required-field">First name</label>
      <input class="dqpl-text-input" type="text" id="required-field" aria-required="true">
      <div class="dqpl-error-wrap"></div>
</div>
.dqpl-label.dqpl-required:after {
    content: 'Required';
...
}

This causes VoiceOver in a modern browser (and possibly other AT/browser combinations) to double announce "required": once for the label text ::after content and again because of the aria attribute. Additionally, the absence of the required attribute may be purposeful, but it's in conflict with the other recommendation.

I think it's best to place aria-hidden or role=presentation on the "required" label text and add the required attribute to the input. If the browser/AT is old and does not support aria/HTML5, then the label text will be read. Otherwise, only the attribute will be announced (and I'm not aware of any AT that double announces for required and aria-required although not all AT honor both).

If this sounds reasonable, I can make a PR.

confirmation toasts: focus or alert?

I see that confirmation toasts are using focus instead of an aria alert role. I'm hearing from other developers (e.g., on the A11Y Slack channel) that shifting focus is "bad UX", and they advocate using aria live regions (e.g., alerts) that disappear after a certain time instead. I honestly don't know which way is better. What is the rationale for relying on focus? Is shifting focus really ok or better for the user than a live region?

Menu submenu trigger swallowing click propagation

Expected behavior: I can implement a menu item with no submenu items or anchors and write a custom onclick listener for it.

Actual behavior: < ul > and < li > in a project using the dqpl-pattern-library have their click listener propagation stopped by this chunk of code at lines 2736-2758:

 /**
     * Mouse logic for expandable submenu triggers
     */

    (0, _delegate2.default)(elements.menu, '[role="menuitem"]', 'click', function (e) {
      e.stopPropagation(); //THIS IS THE PROBLEM CHILD
      var trigger = e.delegateTarget;

      if (trigger.hasAttribute('aria-controls')) {
        toggleSubmenu(trigger, function (submenu, done) {
          (0, _animation.slideToggle)(submenu, function () {
            var toFocus = submenu.querySelector('[role="menuitem"][tabindex="0"]');
            toFocus = toFocus || submenu.querySelector('[role="menuitem"]');
            done(false, toFocus);
          }, 300);
        });
      } else {
        var link = trigger.querySelector('a');
        if (link) {
          link.click();
        }
      }
    });

Suggested solution: do not stop the propagation of the event if there are no submenu items or anchor. A custom class/property could be a simple implementation has-submenu-or-anchor="false" defaulting to true.

question about disabled buttons

Hi,

Just found a link to this library on twitter and started looking around, was just wondering if there any particular reason you need to disable the button using the class 'dqpl-disabled'? Has that anything to do with accessibility?

<button class="dqpl-button-primary dqpl-disabled" type="button">PRIMARY DISABLED</button>

Asking it, because in the above state the button itself would still fire events, while it looks disabled to the user.

If you set the disabled attribute it would not fire events anymore:

<button class="dqpl-button-primary dqpl-disabled" type="button" disabled>PRIMARY DISABLED</button>

And then you could style it using the :disabled pseudo CSS selector (https://developer.mozilla.org/nl/docs/Web/CSS/:disabled) and button[disabled] (if you need to support older browsers).

Then the following markup would work:

<button class="dqpl-button-primary" disabled>PRIMARY DISABLED</button>
button[disabled],
button:disabled {
....
}

Wondering if the above breaks accessibility in some way, because then I got some code to refactor :-)

Thanks,

Erik

Component classes are unnecessarily prefixed

I'm updating our extensions to use a newer version of Cauldron and finding that there is extra CSS preventing a clean switchover. Many All of the classes are prefixed with body .dqpl-layout, which looks like it contains styles for the pattern library site (top: 50px). Those styles shouldn't be applied to things like .dqpl-label, or basic inputs.

For example, this CSS exists on the pattern library demo site, in pattern-library.css:

body .dqpl-layout .dqpl-label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 300;
  margin-bottom: 4px;
  margin-left: 4px;
  cursor: default;
}
body .dqpl-layout .dqpl-label.dqpl-label-disabled {
  color: #cccccc;
}
body .dqpl-layout .dqpl-label.dqpl-required .dqpl-required-text {
  display: inline-block;
  margin-left: 24px;
  font-style: italic;
  font-weight: 400;
}

All of those things are in use in the Attest extension, but we can't use dqpl-layout. Is there a reason why those are prefixed in that way?

Drop fixed position on top bar at low height

When there's limited horizontal space, the top bar should not have a fixed position. Fixed areas are problematic for low vision users, as they take up a bunch of valuable screen space. I suggest if the height is less than 400px, the top bar should stop being sticky.

Typo on wiki page for select component

The section that describes how to set the default selected option of a select component uses an id of "yes" for the aria-activedescendant of the role="combobox" element and the role="option", but has the wrong text content in the element with class="dqpl-pseudo-val". This makes the example misleading.

Adjust the text content of the element with class="dqpl-pseudo-val" to "Yes". I'd do it myself, but these Wikis are under wraps.

Use space in 'Required' label

The wiki currently shows the "require" label in a form field without a space between it and the label. This creates problems for screen readers. I'm not sure what's the best way to do this. I was thinking you might just want to use :before and add inject a space, but you should test if that works with AT.

Utils folder missing in dist/js

dist/js/utils is referenced by pattern-library.js in the same folder but it's not included in the current download from npm (v 2.3.4).

monorepo this

moving cauldron-react here too. We'll end up with:

  • packages/cauldron-styles
  • packages/cauldron-js
  • packages/cauldron-react

Topbar Dropdown keydown goes the wrong way

When using the keyboard to navigate a topBar dropdown and there are at least 3 options within the dropdown. The keydown goes to the prev option (bottom of list) not the next option (below).

Initial opening of menu

Screen Shot 2019-04-18 at 1 52 08 PM

After pressing down arrow

Screen Shot 2019-04-18 at 1 52 23 PM

ftpos are really hard to style

In attempting to setup a quick demo for someone, I quickly realized how hard it is to position all of the parts (wrapper, box, arrow etc..) of the ftpo. Shortly after flailing for a bit, I realized that simply applying position: absolute; to the dqpl-pointer-wrap styling became easy 😄

IMO, dqpl-pointer-wrap should be position absolute by default and allow implementers to change it if needed (99% of ftpos I've seen in the wild are positioned absolutely)

Unable to install with Yarn and node 8.9

The engines field in this library'spackage.json is too strict. I'm unable to install it without errors.

Environment details:

node v8.9.4
yarn 1.3.2

Installation output:

 ∴ yarn init -y
yarn init v1.3.2
warning The yes flag has been set. This will automatically answer yes to all questions which may have security implications.
success Saved package.json
✨  Done in 0.03s.

 ∴ yarn add deque-pattern-library
yarn add v1.3.2
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version "8.1.3".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Review role for Selects Component

I believe the Selects Component might include an incorrect role. It currently features role="combobox", and according to ARIA Authoring Practices 1.1, a combobox is made up of a text input and a list of options, much like an autocomplete component.

When listening to the role descriptions, this component is announced as, "combo box," whereas a native select element is announced as "popup button" (VO + Safari at least.)

When reviewing the "single select" Collapsible Dropdown Listbox demo, which features a button element and aria-haspopup="listbox", this seems to accurately announce the role as one might expect.

Should this component's role be changed from combobox to button and include the aria-haspopup="listbox" attribute to ensure an accurate description? 🤔

Use main-content:focus for other [tabindex=-1] elements

When the main content receives focus, instead of the purple focus ring, it has a bar on the left. This is actually much nicer, and it would be nice if this behaviour could be used on other elements as well. I think we need an option for that bar being inside or outside the focusable element.

Nested state-based widgets handling keyboard events

Example:

A modal is opened with a Select (role=combobox) child. When the user expands the Select, "Escape" should collapse it (but not the modal). If the Select has focus and is collapsed, "Escape" should bubble up to close the modal.

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.