Skip to content
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

adding some basic styles for DL lists #286

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
82 changes: 82 additions & 0 deletions examples/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { PureComponent } from 'react';
import {
Alert,
AppRoot,
Button,
Column,
Expand Down Expand Up @@ -161,6 +162,87 @@ class App extends PureComponent<{}, AppState> {
</Column>
</Row>

<Row>
<Column>
<h3>Definition List Styles</h3>
<Row>
<Column xs={12} sm={4}>
<h4>&lt;dl className="list"&gt;</h4>
<dl className="list">
<dt>Felines</dt>
<dd>Tabby</dd>
<dt>
I'm a really really long label that probably will wrap
</dt>
<dd>
<DabIpsum component="text" />
</dd>
<dd>
<DabIpsum component="text" />
</dd>
<dt>Dogs</dt>
<dd>Lhasa Apso</dd>
<dd>Dalmation</dd>
<dd>Labrador</dd>
</dl>
</Column>
<Column xs={12} sm={4}>
<h4>&lt;dl className="stacked"&gt;</h4>
<dl className="stacked">
<dt>Felines</dt>
<dd>Tabby</dd>
<dt>
I'm a really really long label that probably will wrap
</dt>
<dd>
<DabIpsum component="text" />
</dd>
<dd>
<DabIpsum component="text" />
</dd>
<dt>Dogs</dt>
<dd>Lhasa Apso</dd>
<dd>Dalmation</dd>
<dd>Labrador</dd>
</dl>
</Column>
<Column xs={12} sm={4}>
<h4>&lt;dl className="inline"&gt;</h4>
<dl className="inline">
<dt>Felines</dt>
<dd>Tabby</dd>
<dd>Ginger</dd>
<dd>Persian</dd>
</dl>
<dl className="inline">
<dt>
I'm a really really long label that probably will wrap
</dt>
<dd>
<DabIpsum component="text" />
</dd>
<dd>
<DabIpsum component="text" />
</dd>
</dl>
<dl className="inline">
<dt>Dogs</dt>
<dd>Lhasa Apso</dd>
<dd>Dalmation</dd>
<dd>Labrador</dd>
</dl>
<Alert className="info">
<p>
DL lists are notoriously hard to style, so this is the
best you can do really, so assuming you have markup
control, use seperate DL lists for each group of DT/DDs
</p>
</Alert>
</Column>
</Row>
</Column>
</Row>

<Row>
<Column>
<h2>Can't touch these</h2>
Expand Down
86 changes: 86 additions & 0 deletions src/less/definition-list.examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Used to style definition lists.


#### Example

```js
<Row>
<Column>
<h3>Definition List Styles</h3>
<Row>
<Column xs={12} lg={4}>
<h4>className="list"</h4>
<dl className="list">
<dt>Felines</dt>
<dd>Tabby</dd>
<dt>
I'm a really really long label that probably will wrap
</dt>
<dd>
<DabIpsum component="text" />
</dd>
<dd>
<DabIpsum component="text" />
</dd>
<dt>Dogs</dt>
<dd>Lhasa Apso</dd>
<dd>Dalmation</dd>
<dd>Labrador</dd>
</dl>
</Column>
<Column xs={12} lg={4}>
<h4>className="stacked"</h4>
<dl className="stacked">
<dt>Felines</dt>
<dd>Tabby</dd>
<dt>
I'm a really really long label that probably will wrap
</dt>
<dd>
<DabIpsum component="text" />
</dd>
<dd>
<DabIpsum component="text" />
</dd>
<dt>Dogs</dt>
<dd>Lhasa Apso</dd>
<dd>Dalmation</dd>
<dd>Labrador</dd>
</dl>
</Column>
<Column xs={12} lg={4}>
<h4>className="inline"</h4>
<dl className="inline">
<dt>Felines</dt>
<dd>Tabby</dd>
<dd>Ginger</dd>
<dd>Persian</dd>
</dl>
<dl className="inline">
<dt>
I'm a really really long label that probably will wrap
</dt>
<dd>
<DabIpsum component="text" />
</dd>
<dd>
<DabIpsum component="text" />
</dd>
</dl>
<dl className="inline">
<dt>Dogs</dt>
<dd>Lhasa Apso</dd>
<dd>Dalmation</dd>
<dd>Labrador</dd>
</dl>
<Alert className="info">
<p>
DL lists are notoriously hard to style, so this is the
best you can do really, so assuming you have markup
control, use seperate DL lists for each group of DT/DDs
</p>
</Alert>
</Column>
</Row>
</Column>
</Row>```
77 changes: 77 additions & 0 deletions src/less/text.less
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,80 @@
.error {
color: @error;
}

dl {
margin: 0;
padding: 0;
}

dl + dl {
margin-top: @padding-base;
}

dl.list {
dt {
float: left;
clear: left;
width: @dl-label-width;
text-align: right;
font-weight: @font-weight-bold;
color: @dl-label-color;
}

dt::after {
content: ':';
}

dd {
margin: 0 0 0 @dl-label-width + @padding-base;
padding: 0 0 @margin-base 0;
}
}

dl.stacked {

dt {
font-weight: @font-weight-bold;
color: @dl-label-color;
margin-top: @padding-base;
margin-bottom: @padding-small;

&:first-of-type {
margin-top: 0;
}
}


dd {
margin: 0;
padding: 0;
}
}

dl.inline {

dt,
dd {
display: inline;
padding: 0;
margin: 0;
}

dt {
font-weight: @font-weight-bold;
color: @dl-label-color;
}

dt::after {
content: ':';
margin-right: @margin-base;
}

dd::after {
content: ', ';
}

dd:last-child:after {
content: '';
}
}
3 changes: 3 additions & 0 deletions src/less/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
@label-width: 100px;
@no-label-offset: @label-width + @margin-base;

@dl-label-width: @label-width;
@dl-label-color: @grey-medium;

@textarea-width: @input-width;
@textarea-height: @input-height * 2;

Expand Down
4 changes: 4 additions & 0 deletions styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ var less = [
name: 'Atomic text align classes',
content: 'src/less/text-align.examples.md'
},
{
name: 'Definition Lists',
content: 'src/less/definition-list.examples.md'
},
{
name: 'Variables',
content: 'src/less/variables.examples.md'
Expand Down