Skip to content
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

Text Area Max Length #706

Merged
merged 3 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
[placeholder]="placeholder"
[rows]="rows"
[formControl]="control"
[attr.maxlength]="maxlength || null"
[attr.minlength]="minlength || null"
Copy link
Contributor

Choose a reason for hiding this comment

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

One question I have about this is whether we should be using attr. for these. In the Angular docs it says: "It is recommended that you set an element property with a property binding whenever possible."

Also here it says "Attributes initialize DOM properties and then they are done. Property values can change; attribute values can't." I'm wondering if that means that when you use attr. it makes the binding static (i.e. it won't update if the value is changed)?

These two things make me think maybe we should just property binding here, unless the text-areas don't have these properties.

></textarea>

<go-hint *ngFor="let hint of hints" [message]="hint" [theme]="theme"></go-hint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class GoTextAreaComponent implements OnInit {
@Input() key: string;
@Input() hints: Array<string>;
@Input() label: string;
@Input() maxlength: number;
@Input() minlength: number;
@Input() placeholder: string = '';
@Input() theme: 'light' | 'dark' = 'light';
@Input() rows: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,80 @@ <h4 class="go-heading-4 go-heading--underlined">Code</h4>

</div>
</go-card>

<go-card id="form-textarea-max-length" class="go-column go-column--100">
<ng-container go-card-header>
<h2 class="go-heading-2 go-heading--no-wrap">Component Max Length</h2>
<go-copy cardId="form-textarea-max-length" goCopyCardLink></go-copy>
</ng-container>
<div class="go-container" go-card-content>

<div class="go-column go-column--100">
<p class="go-body-copy go-body-copy--no-margin">
The text area component's max length can be set via
<code class="code-block--inline">@Input() maxlength: number;</code> and the
<code class="code-block--inline">maxlength</code> attribute.
</p>
</div>

<div class="go-column go-column--100 go-column--no-padding">
<div class="go-container">
<div class="go-column go-column--50">
<h4 class="go-heading-4 go-heading--underlined">View</h4>
<go-text-area
[control]="message10"
label="Your Message"
maxlength="10">
</go-text-area>
</div>
<div class="go-column go-column--50">
<h4 class="go-heading-4 go-heading--underlined">Code</h4>
<code
[highlight]="basicMaxLengthExample"
class="code-block--no-bottom-margin">
</code>
</div>
</div>
</div>

</div>
</go-card>

<go-card id="form-textarea-min-length" class="go-column go-column--100">
<ng-container go-card-header>
<h2 class="go-heading-2 go-heading--no-wrap">Component Min Length</h2>
<go-copy cardId="form-textarea-min-length" goCopyCardLink></go-copy>
</ng-container>
<div class="go-container" go-card-content>

<div class="go-column go-column--100">
<p class="go-body-copy go-body-copy--no-margin">
The text area component's min length can be set via
<code class="code-block--inline">@Input() minlength: number;</code> and the
<code class="code-block--inline">minlength</code> attribute.
</p>
</div>

<div class="go-column go-column--100 go-column--no-padding">
<div class="go-container">
<div class="go-column go-column--50">
<h4 class="go-heading-4 go-heading--underlined">View</h4>
<go-text-area
[control]="message11"
label="Your Message"
minlength="2">
</go-text-area>
</div>
<div class="go-column go-column--50">
<h4 class="go-heading-4 go-heading--underlined">Code</h4>
<code
[highlight]="basicMinLengthExample"
class="code-block--no-bottom-margin">
</code>
</div>
</div>
</div>

</div>
</go-card>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class TextAreaDocsComponent implements OnInit {
message7: FormControl = new FormControl('');
message8: FormControl = new FormControl('');
message9: FormControl = new FormControl('');
message10: FormControl = new FormControl('');
message11: FormControl = new FormControl('');

hints: Array<string> = [
'Please type your message here',
Expand Down Expand Up @@ -105,6 +107,22 @@ export class TextAreaDocsComponent implements OnInit {
</go-text-area>
`;

basicMaxLengthExample: string = `
<go-text-area
[control]="message"
label="Your Message"
maxlength="10">
</go-text-area>
`;

basicMinLengthExample: string = `
<go-text-area
[control]="message"
label="Your Message"
minlength="2">
</go-text-area>
`;

constructor(private subNavService: SubNavService) {
this.subNavService.pageTitle = 'Textarea';
this.subNavService.linkToSource = 'https://github.com/mobi/goponents/tree/dev/projects/go-lib/src/lib/components/go-text-area';
Expand Down