-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from kenshoo/refactor-component
Refactor checkbox L2L component
- Loading branch information
Showing
69 changed files
with
4,073 additions
and
1,372 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'> | ||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | ||
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'> |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
|
||
import styles from "./column.scss"; | ||
|
||
const Column = ({ children }) => ( | ||
<div className={styles.column}>{children}</div> | ||
); | ||
|
||
export default Column; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import "../../resources/globals"; | ||
|
||
.column { | ||
display: flex; | ||
flex: 1; | ||
flex-direction: column; | ||
border-right: 1px solid $border-color; | ||
&:last-of-type { | ||
border: 0; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import Column from "./column/column"; | ||
import List from "./list/items_list"; | ||
import NoItems from "./items/no_items"; | ||
import SelectedItem from "./items/selected_item"; | ||
import SelectionStatus from "./selection_status/selection_status"; | ||
|
||
const DestinationList = ({ | ||
selectionStatusRenderer, | ||
selectedIds, | ||
clearAll, | ||
messages, | ||
selectedItems, | ||
itemHeight, | ||
height, | ||
unselectItem, | ||
selectedItemRenderer, | ||
noItemsRenderer | ||
}) => { | ||
const SelectionStatusRenderer = selectionStatusRenderer; | ||
return ( | ||
<Column> | ||
<SelectionStatusRenderer | ||
selected={selectedIds} | ||
clearAll={clearAll} | ||
clearAllMessage={messages.clearAllMessage} | ||
selectedMessage={messages.selectedMessage} | ||
noneSelectedMessage={messages.noneSelectedMessage} | ||
/> | ||
<List | ||
items={selectedItems} | ||
itemHeight={itemHeight} | ||
height={height - 45} | ||
onClick={unselectItem} | ||
renderer={selectedItemRenderer} | ||
noItemsRenderer={noItemsRenderer} | ||
noItemsMessage={messages.noItemsMessage} | ||
/> | ||
</Column> | ||
); | ||
}; | ||
|
||
DestinationList.propTypes = { | ||
selectionStatusRenderer: PropTypes.any, | ||
selectedIds: PropTypes.arrayOf(PropTypes.number), | ||
clearAll: PropTypes.func, | ||
messages: PropTypes.object, | ||
selectedItems: PropTypes.array, | ||
itemHeight: PropTypes.number, | ||
height: PropTypes.number, | ||
unselectItem: PropTypes.func, | ||
selectedItemRenderer: PropTypes.any, | ||
noItemsRenderer: PropTypes.any | ||
}; | ||
|
||
DestinationList.defaultProps = { | ||
selectionStatusRenderer: SelectionStatus, | ||
selectedIds: [], | ||
messages: {}, | ||
selectedItems: [], | ||
itemHeight: 40, | ||
height: 400, | ||
selectedItemRenderer: SelectedItem, | ||
noItemsRenderer: NoItems | ||
}; | ||
|
||
export default DestinationList; |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import classnames from "classnames"; | ||
import Checkbox from "material-ui/Checkbox"; | ||
|
||
import styles from "./item.scss"; | ||
|
||
const Item = ({ | ||
item, | ||
height, | ||
onClick, | ||
withBorder, | ||
checked, | ||
indeterminate | ||
}) => ( | ||
<div | ||
className={classnames(styles.item, { | ||
[styles.with_border]: withBorder, | ||
[styles.selected]: checked | ||
})} | ||
style={{ height }} | ||
onClick={onClick} | ||
> | ||
<Checkbox | ||
type="checkbox" | ||
color="primary" | ||
checked={checked} | ||
indeterminate={indeterminate} | ||
/> | ||
{item.label} | ||
</div> | ||
); | ||
|
||
Item.propTypes = { | ||
item: PropTypes.object, | ||
height: PropTypes.number, | ||
withBorder: PropTypes.bool, | ||
checked: PropTypes.bool, | ||
indeterminate: PropTypes.bool | ||
}; | ||
|
||
Item.defaultProps = { | ||
item: {}, | ||
height: 40, | ||
withBorder: false, | ||
checked: false, | ||
indeterminate: false | ||
}; | ||
|
||
export default Item; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@import "../../resources/globals"; | ||
|
||
.item { | ||
display: flex; | ||
align-items: center; | ||
transition: background-color 0.2s ease-in-out; | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
.selected { | ||
background-color: $selected-background-color; | ||
} | ||
&:hover:not(.selected) { | ||
background-color: $hover-background-color; | ||
} | ||
} | ||
|
||
.selected { | ||
background-color: $selected-background-color; | ||
} | ||
|
||
.with_border { | ||
border-bottom: 1px solid $border-color; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import styles from "./no_items.scss"; | ||
|
||
const NoItems = ({ noItemsMessage }) => ( | ||
<div className={styles.no_items}>{noItemsMessage}</div> | ||
); | ||
|
||
NoItems.propTypes = { | ||
noItemsMessage: PropTypes.string | ||
}; | ||
|
||
NoItems.defaultProps = { | ||
noItemsMessage: "No Items..." | ||
}; | ||
|
||
export default NoItems; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import "../../resources/globals"; | ||
|
||
.no_items { | ||
font-size: $font-large; | ||
color: $placeholder-color; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100%; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import Item from "./item"; | ||
|
||
const SelectAll = ({ | ||
height, | ||
onClick, | ||
isAllSelected, | ||
selectAllMessage, | ||
selectedIds | ||
}) => ( | ||
<Item | ||
height={height} | ||
onClick={onClick} | ||
withBorder | ||
item={{ label: selectAllMessage }} | ||
checked={isAllSelected} | ||
indeterminate={!isAllSelected && selectedIds.length > 0} | ||
/> | ||
); | ||
|
||
SelectAll.propTypes = { | ||
selectAllMessage: PropTypes.string, | ||
height: PropTypes.number, | ||
onClick: PropTypes.func, | ||
isAllSelected: PropTypes.bool, | ||
selectedIds: PropTypes.arrayOf(PropTypes.number) | ||
}; | ||
|
||
SelectAll.defaultProps = { | ||
selectAllMessage: "Select All", | ||
isAllSelected: false, | ||
height: 40, | ||
selectedIds: [] | ||
}; | ||
|
||
export default SelectAll; |
Oops, something went wrong.