Skip to content

Commit

Permalink
feat(lists): Add styles for UnorderedList
Browse files Browse the repository at this point in the history
And create new scss files to share classes between UnorderedList and OrderedList
  • Loading branch information
lzcabrera committed Sep 14, 2017
1 parent 4c9bf97 commit 698a84e
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 28 deletions.
3 changes: 3 additions & 0 deletions src/components/Lists/List.modules.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.base {
padding-left: 40px;
}
5 changes: 5 additions & 0 deletions src/components/Lists/ListItem.modules.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import '../../scss/settings/spacing';

.item {
margin-bottom: $spacing-tight;
}
20 changes: 14 additions & 6 deletions src/components/Lists/OrderedList/OrderedItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ import PropTypes from 'prop-types'

import safeRest from '../../../safeRest'

import styles from '../../Typography/Text/Text.modules.scss'
import textStyles from '../../Typography/Text/Text.modules.scss'
import styles from '../ListItem.modules.scss'

const OrderedItem = ({ size, children, ...rest }) => (
<li {...safeRest(rest)} className={styles[size]}>
{children}
</li>
)
const OrderedItem = ({ size, children, ...rest }) => {
const classes = `
${styles.item}
${textStyles[size]}
`

return (
<li {...safeRest(rest)} className={classes}>
{children}
</li>
)
}

OrderedItem.propTypes = {
size: PropTypes.oneOf([
Expand Down
10 changes: 3 additions & 7 deletions src/components/Lists/OrderedList/OrderedList.modules.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
.base {
padding-left: 40px;
}

.decimal {
composes: base;
composes: base from '../List.modules.scss';

list-style-type: decimal;
}

.upperAlpha {
composes: base;
composes: base from '../List.modules.scss';

list-style-type: upper-alpha;
}

.lowerAlpha {
composes: base;
composes: base from '../List.modules.scss';

list-style-type: lower-alpha;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ exports[`<OrderedList /> renders 1`] = `
class="decimal"
>
<li
class="undefined"
class="
item
undefined
"
>
Lorem ipsum
</li>
<li
class="undefined"
class="
item
undefined
"
>
Dolor sit amet
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
@import '../../../../scss/settings/colours';
@import '../../../../scss/settings/typography';

.item::before {
font-family: $font-icons;
.item {
composes: item from '../../ListItem.modules.scss';
position: relative;

&::before {
display: block;
position: absolute;
left: -24px;

font-family: $font-icons;
}
}

.circle {
composes: item;

&::before {
display: block;
position: absolute;
content: '\002022';
color: $color-telus-purple;
left: -21px;
}
}

Expand All @@ -23,7 +29,6 @@
&::before {
content: "\f101";
color: $color-primary;
left: -33px;
}
}

Expand All @@ -33,6 +38,5 @@
&::before {
content: "\f104";
color: $color-cardinal;
left: -33px;
}
}
2 changes: 1 addition & 1 deletion src/components/Lists/UnorderedList/UnorderedList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { childrenOfType } from 'airbnb-prop-types'
import safeRest from '../../../safeRest'
import UnorderedItem from './UnorderedItem/UnorderedItem'

import styles from './UnorderedList.modules.scss'
import styles from '../List.modules.scss'

const injectSizeAndListStyle = (child, size, listStyle) => (
React.cloneElement(child, { size, listStyle })
Expand Down
5 changes: 0 additions & 5 deletions src/components/Lists/UnorderedList/UnorderedList.modules.scss

This file was deleted.

0 comments on commit 698a84e

Please sign in to comment.