-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo): add checkbox/chip/dropdown/list/select demo
- Loading branch information
Showing
34 changed files
with
1,230 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
function DemoCheckboxController() { | ||
'ngInject'; | ||
|
||
const vm = this; | ||
|
||
///////////////////////////// | ||
// // | ||
// Public attributes // | ||
// // | ||
///////////////////////////// | ||
|
||
/** | ||
* The various type of checkboxes states and status. | ||
* | ||
* @type {Object} | ||
*/ | ||
vm.checkboxes = { | ||
model: { | ||
checked: true, | ||
unchecked: false, | ||
}, | ||
states: { | ||
disabled: true, | ||
}, | ||
}; | ||
} | ||
|
||
///////////////////////////// | ||
|
||
angular.module('lumx-demo').controller('DemoCheckboxController', DemoCheckboxController); | ||
|
||
///////////////////////////// | ||
|
||
export { DemoCheckboxController }; |
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,2 @@ | ||
<main-header></main-header> | ||
<main-content component="checkbox"></main-content> |
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,5 @@ | ||
# Checkbox | ||
|
||
**Checkboxes allow users to select none, one, or more items.** | ||
|
||
<demo-block component="checkbox" partial="default"></demo-block> |
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,31 @@ | ||
<div class="lumx-spacing-margin-bottom-big"> | ||
<lx-checkbox lx-theme="{{ demoBlock.theme }}" ng-model="vm.checkboxes.model.checked"> | ||
<lx-checkbox-label>Checkbox</lx-checkbox-label> | ||
</lx-checkbox> | ||
</div> | ||
|
||
<div class="lumx-spacing-margin-bottom-big"> | ||
<lx-checkbox lx-theme="{{ demoBlock.theme }}" ng-model="vm.checkboxes.model.unchecked"> | ||
<lx-checkbox-label> | ||
Checkbox with help | ||
</lx-checkbox-label> | ||
|
||
<lx-checkbox-help> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed posuere faucibus efficitur. | ||
</lx-checkbox-help> | ||
</lx-checkbox> | ||
</div> | ||
|
||
<lx-checkbox | ||
lx-theme="{{ demoBlock.theme }}" | ||
ng-disabled="vm.checkboxes.states.disabled" | ||
ng-model="vm.checkboxes.model.unchecked" | ||
> | ||
<lx-checkbox-label> | ||
Disable checkbox with help | ||
</lx-checkbox-label> | ||
|
||
<lx-checkbox-help> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed posuere faucibus efficitur. | ||
</lx-checkbox-help> | ||
</lx-checkbox> |
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,115 @@ | ||
import { mdiCheck, mdiClose, mdiCloseCircle, mdiEmail, mdiFilterVariant } from '@lumx/icons'; | ||
|
||
///////////////////////////// | ||
|
||
function DemoChipController(LxNotificationService) { | ||
'ngInject'; | ||
|
||
const vm = this; | ||
|
||
///////////////////////////// | ||
// // | ||
// Public attributes // | ||
// // | ||
///////////////////////////// | ||
|
||
/** | ||
* The icons to use in the template. | ||
* | ||
* @type {Object} | ||
* @constant | ||
* @readonly | ||
*/ | ||
vm.icons = { | ||
mdiCheck, | ||
mdiClose, | ||
mdiCloseCircle, | ||
mdiEmail, | ||
mdiFilterVariant, | ||
}; | ||
|
||
/** | ||
* Indicates if the chip is active or not. | ||
* | ||
* @type {Object} | ||
*/ | ||
vm.isSelected = { | ||
filter: [false], | ||
multiple: [false, false, false, false, false, false], | ||
unique: [false, false, false, false, false, false], | ||
}; | ||
|
||
///////////////////////////// | ||
// // | ||
// Public functions // | ||
// // | ||
///////////////////////////// | ||
|
||
/** | ||
* When the chip has been clicked, display a notification. | ||
*/ | ||
function clickCallback() { | ||
LxNotificationService.success('Callback'); | ||
} | ||
|
||
/** | ||
* Toggle chip selected state. | ||
* | ||
* @param {string} kind The chip kind. | ||
* @param {number} index The chip index. | ||
*/ | ||
function toggleSelected(kind, index) { | ||
vm.isSelected[kind][index] = !vm.isSelected[kind][index]; | ||
|
||
if (kind === 'unique') { | ||
for (let i = 0, len = vm.isSelected.unique.length; i < len; i++) { | ||
if (i !== index) { | ||
vm.isSelected.unique[i] = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Select chip. | ||
* | ||
* @param {string} kind The chip kind. | ||
* @param {number} index The chip index. | ||
*/ | ||
function select(kind, index) { | ||
if (vm.isSelected[kind][index]) { | ||
return; | ||
} | ||
|
||
vm.isSelected[kind][index] = true; | ||
} | ||
|
||
/** | ||
* Unselect chip. | ||
* | ||
* @param {string} kind The chip kind. | ||
* @param {number} index The chip index. | ||
*/ | ||
function unselect(kind, index) { | ||
if (!vm.isSelected[kind][index]) { | ||
return; | ||
} | ||
|
||
vm.isSelected[kind][index] = false; | ||
} | ||
|
||
///////////////////////////// | ||
|
||
vm.clickCallback = clickCallback; | ||
vm.toggleSelected = toggleSelected; | ||
vm.select = select; | ||
vm.unselect = unselect; | ||
} | ||
|
||
///////////////////////////// | ||
|
||
angular.module('lumx-demo').controller('DemoChipController', DemoChipController); | ||
|
||
///////////////////////////// | ||
|
||
export { DemoChipController }; |
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,2 @@ | ||
<main-header></main-header> | ||
<main-content component="chip"></main-content> |
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,34 @@ | ||
# Chip | ||
|
||
**Chips display distinct inputs, attributes, or actions.** | ||
Use chips to display choices, as inputs or to filter content. | ||
|
||
## Default | ||
|
||
Use default to display distinct attributes such as tags on a blog post. | ||
|
||
<demo-block component="chip" partial="default"></demo-block> | ||
|
||
## Dismissible | ||
|
||
Use dismissible when chips can be removed by users. | ||
|
||
<demo-block component="chip" partial="dismissible"></demo-block> | ||
|
||
## Choice | ||
|
||
Use choice when users makes an exclusive choice between values. When space is not a constraint, use this chip instead of a select component. | ||
|
||
<demo-block component="chip" partial="choice"></demo-block> | ||
|
||
## Filter | ||
|
||
Use Filter as an entry point to one or several choices. When it is active, it can have a clear button. | ||
|
||
<demo-block component="chip" partial="filter"></demo-block> | ||
|
||
## Small | ||
|
||
Use small when space is a constraint, as in areas like text fields, selects, dropdown menus and metadata. | ||
|
||
<demo-block component="chip" partial="small"></demo-block> |
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,49 @@ | ||
<demo-grid> | ||
<lx-chip | ||
lx-is-selected="vm.isSelected.unique[0]" | ||
lx-on-click="vm.toggleSelected('unique', 0)" | ||
lx-theme="{{ demoBlock.theme }}" | ||
> | ||
<lx-chip-label>Am</lx-chip-label> | ||
</lx-chip> | ||
|
||
<lx-chip | ||
lx-is-selected="vm.isSelected.unique[1]" | ||
lx-on-click="vm.toggleSelected('unique', 1)" | ||
lx-theme="{{ demoBlock.theme }}" | ||
> | ||
<lx-chip-label>Stram</lx-chip-label> | ||
</lx-chip> | ||
|
||
<lx-chip | ||
lx-is-selected="vm.isSelected.unique[2]" | ||
lx-on-click="vm.toggleSelected('unique', 2)" | ||
lx-theme="{{ demoBlock.theme }}" | ||
> | ||
<lx-chip-label>Gram</lx-chip-label> | ||
</lx-chip> | ||
|
||
<lx-chip | ||
lx-is-selected="vm.isSelected.unique[3]" | ||
lx-on-click="vm.toggleSelected('unique', 3)" | ||
lx-theme="{{ demoBlock.theme }}" | ||
> | ||
<lx-chip-label>Pic</lx-chip-label> | ||
</lx-chip> | ||
|
||
<lx-chip | ||
lx-is-selected="vm.isSelected.unique[4]" | ||
lx-on-click="vm.toggleSelected('unique', 4)" | ||
lx-theme="{{ demoBlock.theme }}" | ||
> | ||
<lx-chip-label>Pic</lx-chip-label> | ||
</lx-chip> | ||
|
||
<lx-chip | ||
lx-is-selected="vm.isSelected.unique[5]" | ||
lx-on-click="vm.toggleSelected('unique', 5)" | ||
lx-theme="{{ demoBlock.theme }}" | ||
> | ||
<lx-chip-label>Colegram</lx-chip-label> | ||
</lx-chip> | ||
</demo-grid> |
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,15 @@ | ||
<demo-grid> | ||
<lx-chip lx-theme="{{ demoBlock.theme }}"> | ||
<lx-chip-label>Default</lx-chip-label> | ||
</lx-chip> | ||
|
||
<lx-chip lx-theme="{{ demoBlock.theme }}"> | ||
<lx-chip-before> | ||
<lx-icon lx-path="{{ vm.icons.mdiEmail }}" lx-size="xs"></lx-icon> | ||
</lx-chip-before> | ||
|
||
<lx-chip-label> | ||
Rich | ||
</lx-chip-label> | ||
</lx-chip> | ||
</demo-grid> |
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,25 @@ | ||
<demo-grid> | ||
<lx-chip lx-theme="{{ demoBlock.theme }}" lx-on-click="vm.clickCallback()"> | ||
<lx-chip-label> | ||
Dismissible | ||
</lx-chip-label> | ||
|
||
<lx-chip-after> | ||
<lx-icon lx-path="{{ vm.icons.mdiClose }}" lx-size="xs"></lx-icon> | ||
</lx-chip-after> | ||
</lx-chip> | ||
|
||
<lx-chip lx-theme="{{ demoBlock.theme }}" lx-on-click="vm.clickCallback()"> | ||
<lx-chip-before> | ||
<lx-icon lx-path="{{ vm.icons.mdiEmail }}" lx-size="xs"></lx-icon> | ||
</lx-chip-before> | ||
|
||
<lx-chip-label> | ||
Dismissible rich | ||
</lx-chip-label> | ||
|
||
<lx-chip-after> | ||
<lx-icon lx-path="{{ vm.icons.mdiClose }}" lx-size="xs"></lx-icon> | ||
</lx-chip-after> | ||
</lx-chip> | ||
</demo-grid> |
Oops, something went wrong.