Skip to content

Commit

Permalink
feat: add primary prop to ListItem
Browse files Browse the repository at this point in the history
  • Loading branch information
fsilvaco authored and arturbien committed Jun 30, 2021
1 parent f82026e commit 5ab9aa2
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 60 deletions.
145 changes: 94 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/List/List.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
export const Default = () => (
<>
<List>
<ListItem>Photos</ListItem>
<ListItem primary>Photos</ListItem>
<ListItem as='a' href='https://expensive.toys' target='_blank'>
Link
</ListItem>
Expand All @@ -41,7 +41,9 @@ export const Default = () => (
<ListItem disabled>Razor Leaf</ListItem>
</List>
<List>
<ListItem size='sm'>View</ListItem>
<ListItem primary size='sm'>
View
</ListItem>
<Divider />
<ListItem size='sm'>Paste</ListItem>
<ListItem size='sm'>Paste Shortcut</ListItem>
Expand Down
11 changes: 7 additions & 4 deletions src/ListItem/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const StyledListItem = styled.li`
line-height: ${props => blockSizes[props.size]};
color: ${({ theme }) => theme.materialText};
pointer-events: ${({ isDisabled }) => (isDisabled ? 'none' : 'auto')};
font-weight: ${({ primary }) => (primary ? 'bold' : 'normal')};
&:hover {
${({ theme, isDisabled }) =>
!isDisabled &&
Expand All @@ -44,6 +44,7 @@ const ListItem = React.forwardRef(function ListItem(props, ref) {
square,
children,
onClick,
primary,
...otherProps
} = props;
// let tabIndex;
Expand All @@ -57,6 +58,7 @@ const ListItem = React.forwardRef(function ListItem(props, ref) {
isDisabled={disabled}
square={square}
onClick={disabled ? undefined : onClick}
primary={primary}
// tabIndex={tabIndex}
role='menuitem'
ref={ref}
Expand All @@ -73,8 +75,8 @@ ListItem.defaultProps = {
size: 'lg',
square: false,
onClick: null,

children: null
children: null,
primary: false
// tabIndex: undefined
};

Expand All @@ -83,7 +85,8 @@ ListItem.propTypes = {
disabled: propTypes.bool,
square: propTypes.bool,
children: propTypes.node,
onClick: propTypes.func
onClick: propTypes.func,
primary: propTypes.bool
// tabIndex: propTypes.number
};

Expand Down
16 changes: 13 additions & 3 deletions src/ListItem/ListItem.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ menu: Components

import { Playground, Props } from 'docz';

import ListItem from './ListItem'
import List from '../List/List'
import Divider from '../Divider/Divider'
import ListItem from './ListItem';
import List from '../List/List';
import Divider from '../Divider/Divider';

# ListItem

Expand Down Expand Up @@ -83,6 +83,16 @@ import Divider from '../Divider/Divider'
</List>
</Playground>

#### Primary

<Playground>
<List>
<ListItem primary>Item 1</ListItem>
<ListItem>Item 2</ListItem>
<ListItem>Item 3</ListItem>
</List>
</Playground>

## API

### Import
Expand Down

1 comment on commit 5ab9aa2

@vercel
Copy link

@vercel vercel bot commented on 5ab9aa2 Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.