Skip to content

Commit

Permalink
Merge pull request #3052 from Akshat55/expressive-list
Browse files Browse the repository at this point in the history
feat: allow list to be expressive
  • Loading branch information
zvonimirfras authored Nov 12, 2024
2 parents b858e05 + a786eeb commit 0e072f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 11 additions & 1 deletion src/list/list.directive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Directive, ElementRef, HostBinding } from "@angular/core";
import {
Directive,
ElementRef,
HostBinding,
Input
} from "@angular/core";

/**
* Applies either ordered or unordered styling to the list container it is applied to.
Expand Down Expand Up @@ -33,5 +38,10 @@ export class List {
return !!(this.elementRef.nativeElement.parentElement && this.elementRef.nativeElement.parentElement.tagName === "LI");
}

/**
* Set to `true` to make list expressive
*/
@Input() @HostBinding("class.cds--list--expressive") isExpressive = false;

constructor(protected elementRef: ElementRef) {}
}
13 changes: 8 additions & 5 deletions src/list/list.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ export default {
parameters: {
layout: "centered"
},
args: {
isExpressive: false
},
component: List
} as Meta;

const Template = (args) => ({
props: args,
template: `
<p>Ordered List</p>
<ol cdsList>
<ol cdsList [isExpressive]="isExpressive">
<li cdsListItem>One</li>
<li cdsListItem>Two</li>
<li cdsListItem>Three</li>
</ol>
<p>Unordered List</p>
<ul cdsList>
<ul cdsList [isExpressive]="isExpressive">
<li cdsListItem>One</li>
<li cdsListItem>Two</li>
<li cdsListItem>Three</li>
Expand All @@ -39,7 +42,7 @@ const NestingTemplate = (args) => ({
props: args,
template: `
<p>Ordered List</p>
<ol cdsList>
<ol cdsList [isExpressive]="isExpressive">
<li cdsListItem>
One
<ol cdsList>
Expand All @@ -52,10 +55,10 @@ const NestingTemplate = (args) => ({
<li cdsListItem>Three</li>
</ol>
<p>Unordered List</p>
<ul cdsList>
<ul cdsList [isExpressive]="isExpressive">
<li cdsListItem>
One
<ul cdsList>
<ul cdsList [isExpressive]="isExpressive">
<li cdsListItem>Nested one</li>
<li cdsListItem>Nested two</li>
<li cdsListItem>Nested three</li>
Expand Down

0 comments on commit 0e072f0

Please sign in to comment.