Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions modules/primer-utilities/docs/details.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Details
status: New release
---

Details classes are created to enhance the native behaviors of `<details>`.

{:toc}

## Fullscreen click area

Use `.details-overlay` to expand the click area of `<summary>` to cover the full screen, so user can click anywhere on a page to close `<details>`.

```html
<details class="details-overlay">
<summary class="btn">More</summary>
<div class="position-relative bg-white p-3 border" style="z-index: 100">Hidden text</div>
</details>
```

## Darkened fullscreen click area

Use `.details-overlay-dark` darken the click area overlay. Useful for modals.

```html
<details class="details-overlay details-overlay-dark">
<summary class="btn">More</summary>
<div class="position-relative bg-white p-3 border" style="z-index: 100">Hidden text</div>
</details>
```
1 change: 1 addition & 0 deletions modules/primer-utilities/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import "./lib/borders.scss";
@import "./lib/box-shadow.scss";
@import "./lib/colors.scss";
@import "./lib/details.scss";
@import "./lib/flexbox.scss";
@import "./lib/layout.scss";
@import "./lib/margin.scss";
Expand Down
17 changes: 17 additions & 0 deletions modules/primer-utilities/lib/details.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// stylelint-disable selector-max-type
.details-overlay[open] > summary::before {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 99;
display: block;
cursor: default;
content: " ";
background: transparent;
}

.details-overlay-dark[open] > summary::before {
background: $black-fade-50;
}
16 changes: 16 additions & 0 deletions modules/primer-utilities/stories/Details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react'
import { storiesOf } from '@storybook/react'

storiesOf('Details utilities', module)
.add('details-overlay', () => (
<details className='details-overlay'>
<summary className='btn'>More</summary>
<div className='position-relative bg-white p-3 border' style={{zIndex: 100}}>Hidden text</div>
</details>
))
.add('details-overlay-dark', () => (
<details className='details-overlay details-overlay-dark'>
<summary className='btn'>More</summary>
<div className='position-relative bg-white p-3 border' style={{zIndex: 100}}>Hidden text</div>
</details>
))