-
Notifications
You must be signed in to change notification settings - Fork 7
MARKET-1557 List Component #178
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
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
71c071e
Add list-component
Fialkaksu d89e697
Add readme
Fialkaksu 4a56f91
Edit readme
Fialkaksu 13cba78
Added styles
Fialkaksu 73c8ed4
Add nested lists
Fialkaksu 217c5f1
fixes by review
Fialkaksu a2946e7
minor edits
Fialkaksu d733da6
code refactoring
Fialkaksu 65cfa59
code edits and modified preview
Fialkaksu 8c664c0
minor edits
Fialkaksu a436837
minor edits and updates
Fialkaksu f82cdde
minor edits
Fialkaksu 7c7e957
added elRef
Fialkaksu bad8f87
updated Props table
Fialkaksu 2ea85f2
code edits, update readme
Fialkaksu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| # List | ||
|
|
||
| List is the component that can be used in Backendless [UI-Builder](https://backendless.com/developers/#ui-builder). It allows you to add a standard list to your application. Select the type of list (ordered/unordered) and specify the data that will be displayed inside the list. | ||
| More information about list you can find [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li). | ||
|
|
||
| <p align="center"> | ||
| <img src="./thumbnail.png" alt="main thumbnail" width="780"/> | ||
| </p> | ||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Type | Default value | Logic | Data Binding | UI Setting | Description | | ||
| |------------|-----------------------------------------------|---------------|-----------------|--------------|------------|--------------------------------------------------------------------------------------------------| | ||
| | Type | *Select* <br> `'Unordered'` <br> `'Ordered'` | `Unordered` | Type Logic | NO | YES | Controls the type of list(ul/ol). | | ||
| | List Items | *JSON* <br> `[...{content:'', ?children:[]}]` | `[]` | ListItems Logic | YES | NO | Specifies a JSON array containing data of the list items. Watch [Codeless Examples] (#Examples). | | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| | Background | *Color* | | | NO | YES | Controls the background color of the main block. | | ||
| | Width | *Text* | | | NO | YES | Controls the width of the main block. | | ||
| | Color | *Color* | | | NO | YES | Controls the color of the list items. | | ||
| | Font Size | *Text* | | | NO | YES | Controls the font size of the list items. | | ||
|
|
||
| ## Events | ||
|
|
||
| | Name | Triggers | Context Blocks | | ||
| |---------------------------|--------------------------------------------------------|----------------| | ||
| | On Click List Item | when the user click any item of the list | `List Item` | | ||
|
|
||
| ## Styles | ||
|
|
||
| **Theme** | ||
| ```` | ||
| @bl-customComponent-list-theme: @themePrimary; | ||
| @bl-customComponent-list-themeTextColor: @appTextColor; | ||
| ```` | ||
|
|
||
| **Dimensions** | ||
| ``` | ||
| @bl-customComponent-list-item-size: 20px; | ||
| ``` | ||
|
|
||
| **Colors** | ||
| ```` | ||
| @bl-customComponent-list-item-hover-background-color: if(@isLightTheme, rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.04)); | ||
| ```` | ||
|
|
||
| ## Examples | ||
|
|
||
| Below is a Codeless Example highlighting how to use the List component: | ||
|
|
||
|  | ||
|  | ||
v-excelsior marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+8.9 KB
components/bl-list-component/example-images/list-data-example-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 { useMemo } from 'react' | ||
|
|
||
| import { List } from './list' | ||
|
|
||
| const { cn } = BackendlessUI.CSSUtils | ||
|
|
||
| export default function ListComponent ({ component, eventHandlers }) { | ||
|
|
||
v-excelsior marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const { style, classList, width, backgroundColor } = component | ||
|
|
||
| const styles = useMemo(() => ({ style, width, backgroundColor }), [style, width, backgroundColor]) | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return ( | ||
| <div className={ cn('bl-customComponent-list', classList) } style={ styles }> | ||
| <List as={ component.type } component={ component } eventHandlers={ eventHandlers }/> | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or 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,29 @@ | ||
| import { List } from './list' | ||
|
|
||
| export function ListContent({ component, eventHandlers, children }) { | ||
|
|
||
| const { color, fontSize, listItems } = component | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const onItemClick = (e, key) => { | ||
| e.stopPropagation() | ||
| eventHandlers.onClickListItem({ item: key }) | ||
| } | ||
|
|
||
| return (children || listItems || []).map((item, i) => ( | ||
| <li | ||
| key={ i } | ||
| className="list__item" | ||
| style={{ color: color, fontSize: fontSize }} | ||
| onClick={ e => onItemClick(e, item) } | ||
| > | ||
| { item.content } | ||
| { item.children && ( | ||
| <List | ||
| component={ component } | ||
| children={ item.children } | ||
| eventHandlers={ eventHandlers } | ||
| /> | ||
| ) } | ||
| </li> | ||
| )) | ||
| } | ||
This file contains hidden or 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,16 @@ | ||
| import { ListContent } from './list-content' | ||
|
|
||
| export function List ({ component, eventHandlers, children, as=component.type }) { | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const Component = as | ||
|
|
||
| return ( | ||
| <Component className="list"> | ||
| <ListContent | ||
| component={ component } | ||
| children={ children } | ||
| eventHandlers={ eventHandlers } | ||
| /> | ||
| </Component> | ||
| ) | ||
| } | ||
This file contains hidden or 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,25 @@ | ||
| @bl-customComponent-list-theme: @themePrimary; | ||
| @bl-customComponent-list-themeTextColor: @appTextColor; | ||
|
|
||
| @bl-customComponent-list-item-hover-background-color: if(@isLightTheme, rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.04)); | ||
|
|
||
| @bl-customComponent-list-item-size: 20px; | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .bl-customComponent-list { | ||
| color: @bl-customComponent-list-themeTextColor; | ||
| user-select: none; | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .list { | ||
| margin: @bl-customComponent-list-item-size; | ||
| } | ||
|
|
||
| .list__item { | ||
| padding: @bl-customComponent-list-item-size / 2; | ||
| line-height: 1.3; | ||
| cursor: pointer; | ||
|
|
||
| &:hover { | ||
| background-color: @bl-customComponent-list-item-hover-background-color; | ||
| } | ||
| } | ||
| } | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.