-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(list): Updates to UnorderedList
Use listStyle instead of bulletType or variant and also remove base option from size prop for both Ordered and Unordered List
- Loading branch information
Showing
8 changed files
with
200 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,15 +1,22 @@ | ||
``` | ||
<UnorderedList> | ||
<UnorderedList listStyle="circle"> | ||
<UnorderedList.Item>Optik Internet 25 | ||
<UnorderedList> | ||
<UnorderedList listStyle="checkmark"> | ||
<UnorderedList.Item>Optik Internet 25</UnorderedList.Item> | ||
<UnorderedList.Item>Internet 25</UnorderedList.Item> | ||
<UnorderedList.Item>Optik High Speed Turbo</UnorderedList.Item> | ||
<UnorderedList.Item>High Speed Turbo 25</UnorderedList.Item> | ||
</UnorderedList> | ||
</UnorderedList.Item> | ||
<UnorderedList.Item>Internet 25</UnorderedList.Item> | ||
<UnorderedList.Item>Optik High Speed Turbo</UnorderedList.Item> | ||
<UnorderedList.Item>Optik High Speed Turbo | ||
<UnorderedList listStyle="x"> | ||
<UnorderedList.Item>Optik Internet 25</UnorderedList.Item> | ||
<UnorderedList.Item>Internet 25</UnorderedList.Item> | ||
<UnorderedList.Item>Optik High Speed Turbo</UnorderedList.Item> | ||
<UnorderedList.Item>High Speed Turbo 25</UnorderedList.Item> | ||
</UnorderedList> | ||
</UnorderedList.Item> | ||
<UnorderedList.Item>High Speed Turbo 25</UnorderedList.Item> | ||
</UnorderedList> | ||
``` |
48 changes: 43 additions & 5 deletions
48
src/components/Lists/UnorderedList/UnorderedList.modules.scss
This file contains 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 |
---|---|---|
@@ -1,15 +1,53 @@ | ||
@import '../../../scss/settings/colours'; | ||
@import '../../../scss/settings/typography'; | ||
|
||
.base { | ||
padding-left: 40px; | ||
position: relative; | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
.fixedWidth { | ||
width: 2rem; | ||
.item { | ||
font-family: $font-icons; | ||
} | ||
|
||
// .icon { | ||
// color: $color-telus-purple; | ||
// } | ||
.circle { | ||
composes: base; | ||
} | ||
|
||
.circleItem::before { | ||
// composes: item; | ||
font-family: $font-icons; | ||
|
||
display: block; | ||
position: absolute; | ||
content: '\002022'; | ||
color: $color-telus-purple; | ||
left: -21px; | ||
} | ||
|
||
.checkmark { | ||
composes: base; | ||
} | ||
|
||
.checkmarkItem::before { | ||
// composes: item; | ||
font-family: $font-icons; | ||
|
||
content: "\f101"; | ||
color: $color-primary; | ||
left: -33px; | ||
} | ||
|
||
.x { | ||
composes: base; | ||
} | ||
|
||
.xItem::before { | ||
// composes: item; | ||
font-family: $font-icons; | ||
|
||
content: "\f104"; | ||
color: $color-cardinal; | ||
left: -33px; | ||
} |
65 changes: 51 additions & 14 deletions
65
src/components/Lists/UnorderedList/__tests__/UnorderedList.spec.jsx
This file contains 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 |
---|---|---|
@@ -1,32 +1,69 @@ | ||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
import { shallow, render } from 'enzyme' | ||
import toJson from 'enzyme-to-json' | ||
|
||
import Text from '../../../Typography/Text/Text' | ||
import UnorderedList from '../UnorderedList' | ||
|
||
describe('<UnorderedList />', () => { | ||
const defaultChildren = '<li>One</li><li>Two</li>' | ||
const doShallow = (props = {}, children = defaultChildren) => ( | ||
shallow(<UnorderedList {...props}>{children}</UnorderedList>) | ||
const doRender = (overrides = {}) => render( | ||
<UnorderedList {...overrides}> | ||
<UnorderedList.Item>Lorem ipsum</UnorderedList.Item> | ||
<UnorderedList.Item>Dolor sit amet</UnorderedList.Item> | ||
</UnorderedList> | ||
) | ||
|
||
const doShallowList = (overrides = {}) => shallow( | ||
<UnorderedList {...overrides}> | ||
<UnorderedList.Item>Lorem ipsum</UnorderedList.Item> | ||
<UnorderedList.Item>Dolor sit amet</UnorderedList.Item> | ||
</UnorderedList> | ||
) | ||
|
||
const findUnorderedList = unorderedList => unorderedList.find('ul') | ||
|
||
const doShallowItem = (overrides = {}) => shallow( | ||
<UnorderedList.Item {...overrides}>Some content</UnorderedList.Item> | ||
) | ||
|
||
it('renders', () => { | ||
const unorderedList = doShallow() | ||
const unorderedList = doRender() | ||
|
||
expect(toJson(unorderedList)).toMatchSnapshot() | ||
}) | ||
|
||
it('renders an HTML ul tag', () => { | ||
const unorderedList = doShallow() | ||
const unorderedList = doShallowList() | ||
|
||
expect(unorderedList).toHaveTagName('Text') | ||
}) | ||
|
||
it('UnOrderList.Item renders an HTML li tag', () => { | ||
const unorderedListItem = doShallowItem() | ||
|
||
expect(unorderedList).toHaveTagName('ul') | ||
expect(unorderedListItem).toHaveTagName('li') | ||
expect(unorderedListItem).toContainReact(<Text>Some content</Text>) | ||
}) | ||
|
||
// it('can have a list style', () => { | ||
// let unorderedList = doShallow({ listStyle: undefined }) | ||
// expect(unorderedList).toHaveClassName('bullet') | ||
// | ||
// unorderedList = doShallow({ listStyle: 'checkmark' }) | ||
// expect(unorderedList).toHaveClassName('checkmark') | ||
// }) | ||
it('can have a list style', () => { | ||
let unorderedList = doShallowList({ listStyle: undefined }) | ||
expect(findUnorderedList(unorderedList)).toHaveClassName('circle') | ||
|
||
unorderedList = doShallowList({ listStyle: 'x' }) | ||
expect(findUnorderedList(unorderedList)).toHaveClassName('x') | ||
}) | ||
|
||
it('passes additional attributes to ul element', () => { | ||
const unorderedList = doShallowList({ id: 'the-list', tabindex: 1 }) | ||
|
||
expect(findUnorderedList(unorderedList)).toHaveProp('id', 'the-list') | ||
expect(findUnorderedList(unorderedList)).toHaveProp('tabindex', 1) | ||
}) | ||
|
||
it('does not allow custom CSS', () => { | ||
const unorderedList = doShallowList({ className: 'my-custom-class', style: { color: 'hotpink' } }) | ||
|
||
expect(findUnorderedList(unorderedList)).not.toHaveProp('className', 'my-custom-class') | ||
expect(findUnorderedList(unorderedList)).not.toHaveProp('style') | ||
}) | ||
}) |
42 changes: 37 additions & 5 deletions
42
src/components/Lists/UnorderedList/__tests__/__snapshots__/UnorderedList.spec.jsx.snap
This file contains 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 |
---|---|---|
@@ -1,12 +1,44 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<UnorderedList /> renders 1`] = ` | ||
<ul | ||
className=" | ||
<span | ||
class=" | ||
base | ||
bullet | ||
baseFont | ||
color | ||
" | ||
> | ||
<li>One</li><li>Two</li> | ||
</ul> | ||
<ul | ||
class=" | ||
circle | ||
" | ||
> | ||
<li | ||
class="circleItem" | ||
> | ||
<span | ||
class=" | ||
base | ||
baseFont | ||
color | ||
" | ||
> | ||
Lorem ipsum | ||
</span> | ||
</li> | ||
<li | ||
class="circleItem" | ||
> | ||
<span | ||
class=" | ||
base | ||
baseFont | ||
color | ||
" | ||
> | ||
Dolor sit amet | ||
</span> | ||
</li> | ||
</ul> | ||
</span> | ||
`; |