mirror of
https://github.com/primer/css.git
synced 2024-11-28 13:12:16 +03:00
Add utility classes for <details>
This commit is contained in:
parent
ae5141a3d7
commit
ac14cc9498
30
modules/primer-utilities/docs/details.md
Normal file
30
modules/primer-utilities/docs/details.md
Normal file
@ -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-expanded` 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-expanded">
|
||||
<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-expanded-dark` darken the click area overlay. Useful for modals.
|
||||
|
||||
```html
|
||||
<details class="details-expanded details-expanded-dark">
|
||||
<summary class="btn">More</summary>
|
||||
<div class="position-relative bg-white p-3 border" style="z-index: 100">Hidden text</div>
|
||||
</details>
|
||||
```
|
@ -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";
|
||||
|
17
modules/primer-utilities/lib/details.scss
Normal file
17
modules/primer-utilities/lib/details.scss
Normal file
@ -0,0 +1,17 @@
|
||||
// stylelint-disable selector-max-type
|
||||
.details-expanded[open] > summary::before {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 99;
|
||||
display: block;
|
||||
cursor: default;
|
||||
content: " ";
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.details-expanded-dark[open] > summary::before {
|
||||
background: $black-fade-50;
|
||||
}
|
16
modules/primer-utilities/stories/Details.js
Normal file
16
modules/primer-utilities/stories/Details.js
Normal file
@ -0,0 +1,16 @@
|
||||
import React from 'react'
|
||||
import { storiesOf } from '@storybook/react'
|
||||
|
||||
storiesOf('Details utilities', module)
|
||||
.add('details-expanded', () => (
|
||||
<details className='details-expanded'>
|
||||
<summary className='btn'>More</summary>
|
||||
<div className='position-relative bg-white p-3 border' style={{zIndex: 100}}>Hidden text</div>
|
||||
</details>
|
||||
))
|
||||
.add('details-expanded-dark', () => (
|
||||
<details className='details-expanded details-expanded-dark'>
|
||||
<summary className='btn'>More</summary>
|
||||
<div className='position-relative bg-white p-3 border' style={{zIndex: 100}}>Hidden text</div>
|
||||
</details>
|
||||
))
|
Loading…
Reference in New Issue
Block a user