-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add 'Popover' component #383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6e350f8
Added `Fixes #` into the PR template
agisilaos 9e13c39
Make a checklist out of the 3 sentences
agisilaos 478f764
Added a space between the # and the (
agisilaos 5dbec5c
Merge pull request #374 from agisilaos/agis/prtemplate
jonrohan 23e4fbc
Merge branch 'master' into dev
jonrohan ea3ed60
Init .Popover
brandonrosage 17d1a9f
Stable CSS-only 'Popover' component
brandonrosage 4500309
Refactored to include `.Popover-message`
brandonrosage a7a8a4f
STorybook menu naming revision
brandonrosage 760ceb1
Tweak caret alignment to overlap border.
brandonrosage 13bf797
make Popover positioning more flexible
brandonrosage d23ce98
Support for top, right, left, bottom caret orientations
brandonrosage 529fdb6
build error fix
brandonrosage 4c6e9f0
Addresses @broccolini's feedback
brandonrosage dc3ab87
Tweak caret alignment
brandonrosage d4e6313
Reconciling documentation differences from Style Guide
brandonrosage 6ae4002
Addresses @broccolini's feedback
brandonrosage ee50150
add peer dependency for Box component
broccolini dac9464
add toc
broccolini 15d89f3
missed a couple of spacers
broccolini 06feed4
Merge branch 'release-10.0.0' into popover
broccolini f7a9309
missed a comma
broccolini 4938e89
update year on license
broccolini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| The MIT License (MIT) | ||
|
|
||
| Copyright (c) 2016 GitHub Inc. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| # Primer CSS Popover | ||
|
|
||
| [](https://www.npmjs.org/package/primer-popover) | ||
| [](https://travis-ci.org/primer/primer-css) | ||
|
|
||
| > Popover for suggesting, guiding, and bringing attention to specific UI elements on a page. | ||
|
|
||
| This repository is a module of the full [primer-css][primer-css] repository. | ||
|
|
||
| ## Install | ||
|
|
||
| This repository is distributed with [npm]. After [installing npm][install-npm], you can install `primer-popover` with this command. | ||
|
|
||
| ``` | ||
| $ npm install --save primer-popover | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| The source files included are written in [Sass][sass] (SCSS) You can simply point your sass `include-path` at your `node_modules` directory and import it like this. | ||
|
|
||
| ```scss | ||
| @import "primer-popover/index.scss"; | ||
| ``` | ||
|
|
||
| You can also import specific portions of the module by importing those partials from the `/lib/` folder. _Make sure you import any requirements along with the modules._ | ||
|
|
||
| ## Build | ||
|
|
||
| For a compiled **CSS** version of this module, an npm script is included that will output a css version to `build/build.css` The built css file is also included in the npm package: | ||
|
|
||
| ``` | ||
| $ npm run build | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| <!-- %docs | ||
| title: Popover | ||
| status: Experimental | ||
| --> | ||
|
|
||
| Popovers are used to bring attention to specific user interface elements, typically to suggest an action or to guide users through a new experience. | ||
|
|
||
| {:toc} | ||
|
|
||
| Popover's consist of: | ||
|
|
||
| - The block element, `.Popover`, which simply positions its content absolutely atop other body content. | ||
| - The child element, `.Popover-message`, which contains the markup for the intended messaging and the visual "caret." | ||
|
|
||
| In the examples below, `Popover-message`, in particular, uses a handful of utility classes to style it appropriately. And these are intended to demonstrate the default, go-to presentation for the popover's message. By default, the message's caret is centered on the top edge of the message. | ||
|
|
||
| The `Popover-message` element also supports several modifiers, most of which position the caret differently: | ||
|
|
||
| - `.Popover-message--top` (default): Places the caret on the top edge of the message, horizontally centered. | ||
| - `.Popover-message--bottom`: Places the caret on the bottom edge of the message, horizontally centered. | ||
| - `.Popover-message--right`: Places the caret on the right edge of the message, vertically centered. | ||
| - `.Popover-message--left`: Places the caret on the left edge of the message, vertically centered. | ||
|
|
||
| Each of these modifiers also support a syntax for adjusting the positioning the caret to the right, left, top, or bottom of its respective edge. That syntax looks like: | ||
|
|
||
| - `.Popover-message--top--right` | ||
| - `.Popover-message--right--top` | ||
| - `.Popover-message--bottom--left` | ||
| - `.Popover-message--left--bottom` | ||
|
|
||
| Lastly, there is an added `.Popover-message--large` modifier, which assumes a slightly wider popover message on screens wider than 544px. | ||
|
|
||
| ### Notes | ||
|
|
||
| The samples below include optional markup, like: | ||
| - An outermost container that establishes stacking context (e.g. `position-relative`). | ||
| - A choice piece of user interface (a button, in this case) to relate the popover to. | ||
| - Use of the `Details` and `js-details` family of class names, which interact with JavaScript to demonstrate dismissal of the popover by clicking the nested "Got it!" button. | ||
|
|
||
| ### Basic example | ||
| Defaults to caret oriented top-center. | ||
|
|
||
| ```html title="Default (top-center)" | ||
| <div class="position-relative text-center"> | ||
| <button class="btn btn-primary">UI</button> | ||
| <div class="Popover right-0 left-0"> | ||
| <div class="Popover-message text-left p-4 mt-2 mx-auto Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Large example | ||
|
|
||
| ```html title="Large" | ||
| <div class="position-relative text-center"> | ||
| <button class="btn btn-primary">UI</button> | ||
| <div class="Popover right-0 left-0"> | ||
| <div class="Popover-message Popover-message--large text-left p-4 mt-2 Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Top-right-aligned example | ||
|
|
||
| ```html title="Top-right" | ||
| <div class="position-relative text-right"> | ||
| <button class="btn btn-primary">UI</button> | ||
| <div class="Popover right-0"> | ||
| <div class="Popover-message Popover-message--top--right text-left p-4 mt-2 Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Top-right-aligned example | ||
|
|
||
| ```html title="Top-left" | ||
| <div class="position-relative"> | ||
| <button class="btn btn-primary">UI</button> | ||
| <div class="Popover"> | ||
| <div class="Popover-message Popover-message--top--left p-4 mt-2 Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Right-aligned example | ||
|
|
||
| ```html title="Right" | ||
| <div class="Popover"> | ||
| <div class="Popover-message Popover-message--right p-4 mt-2 Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Left-aligned example | ||
|
|
||
| ```html title="Left" | ||
| <div class="Popover"> | ||
| <div class="Popover-message Popover-message--left p-4 mt-2 Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Bottom-aligned example | ||
|
|
||
| ```html title="Bottom" | ||
| <div class="Popover"> | ||
| <div class="Popover-message Popover-message--bottom p-4 mt-2 mx-auto Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Bottom-right-aligned example | ||
|
|
||
| ```html title="Bottom-right" | ||
| <div class="Popover"> | ||
| <div class="Popover-message Popover-message--bottom--right p-4 mt-2 mx-auto Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| ### Bottom-left-aligned example | ||
|
|
||
| ```html title="Bottom-left" | ||
| <div class="Popover"> | ||
| <div class="Popover-message Popover-message--bottom--left p-4 mt-2 mx-auto Box box-shadow-large"> | ||
| <h4 class="mb-2">Popover heading</h4> | ||
| <p>Message about this particular piece of UI.</p> | ||
| <button type="submit" class="btn btn-outline mt-2 text-bold">Got it!</button> | ||
| </div> | ||
| </div> | ||
| ``` | ||
|
|
||
| <!-- %enddocs --> | ||
|
|
||
| ## License | ||
|
|
||
| [MIT](./LICENSE) © [GitHub](https://github.com/) | ||
|
|
||
| [primer-css]: https://github.com/primer/primer | ||
| [docs]: http://primercss.io/ | ||
| [npm]: https://www.npmjs.com/ | ||
| [install-npm]: https://docs.npmjs.com/getting-started/installing-node | ||
| [sass]: http://sass-lang.com/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // support files | ||
| @import "primer-support/index.scss"; | ||
| @import "./lib/popover.scss"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a button here made me want to click on it to show/hide the popover because it kind of looks like a dropdown. Might be better to change this to a gray box with text along the lines of "New feature you want to draw attention to".