This repository was archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(linear-progress): Convert JS to TypeScript #4272
Merged
acdvorak
merged 14 commits into
feat/typescript
from
feat/typescript--animation--linear-progress
Jan 23, 2019
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d76279d
feat(animation): Convert JS to TypeScript
acdvorak 3a874f5
feat(linear-progress): Convert JS to TypeScript
acdvorak ec6de3f
WIP: Create enums for argument/return values; update usages to pass enum
acdvorak 9145b18
WIP: Destructure enum members to make their usages more readable
acdvorak f331dae
WIP: Remove "Usage within Web Frameworks" heading
acdvorak 8ce644c
WIP: Replace hard-coded string in README with fully-qualified enum ref
acdvorak a76fa79
WIP: Replace remaining hard-coded strings with fully-qualified enum refs
acdvorak 73ae286
WIP: Inline 2 destructured enum members to avoid variable name confusion
acdvorak f4615bb
Merge branch 'feat/typescript--animation' into feat/typescript--anima…
acdvorak af3dd06
WIP: Remove unnecessary `tslint:disable:no-empty`
acdvorak d8caf25
WIP: Nullable return types for adapter methods that return `HTMLEleme…
acdvorak 2ef55ca
WIP: Remove unnecessary `transformStyleProperties`
acdvorak 55e3642
Merge branch 'feat/typescript' into feat/typescript--animation--linea…
acdvorak 2eb71c9
WIP: Remove `export default`
acdvorak 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
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
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,33 @@ | ||
/** | ||
* @license | ||
* Copyright 2019 Google Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
interface MDCLinearProgressAdapter { | ||
addClass(className: string): void; | ||
getBuffer(): HTMLElement | null; | ||
getPrimaryBar(): HTMLElement | null; | ||
hasClass(className: string): boolean; | ||
removeClass(className: string): void; | ||
setStyle(el: HTMLElement, styleProperty: string, value: string): void; | ||
} | ||
|
||
export {MDCLinearProgressAdapter}; |
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
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
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 |
---|---|---|
|
@@ -26,24 +26,24 @@ import MDCLinearProgressFoundation from './foundation'; | |
|
||
export {MDCLinearProgressFoundation}; | ||
|
||
export class MDCLinearProgress extends MDCComponent { | ||
static attachTo(root) { | ||
export class MDCLinearProgress extends MDCComponent<MDCLinearProgressFoundation> { | ||
static attachTo(root: Element) { | ||
return new MDCLinearProgress(root); | ||
} | ||
|
||
set determinate(value) { | ||
set determinate(value: boolean) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ts compiler says it is returning a boolean. Is that correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No; I tried adding a return value and got a TypeScript error:
|
||
this.foundation_.setDeterminate(value); | ||
} | ||
|
||
set progress(value) { | ||
set progress(value: number) { | ||
this.foundation_.setProgress(value); | ||
} | ||
|
||
set buffer(value) { | ||
set buffer(value: number) { | ||
this.foundation_.setBuffer(value); | ||
} | ||
|
||
set reverse(value) { | ||
set reverse(value: boolean) { | ||
this.foundation_.setReverse(value); | ||
} | ||
|
||
|
@@ -57,12 +57,12 @@ export class MDCLinearProgress extends MDCComponent { | |
|
||
getDefaultFoundation() { | ||
return new MDCLinearProgressFoundation({ | ||
addClass: (className) => this.root_.classList.add(className), | ||
getPrimaryBar: () => this.root_.querySelector(MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR), | ||
addClass: (className: string) => this.root_.classList.add(className), | ||
getBuffer: () => this.root_.querySelector(MDCLinearProgressFoundation.strings.BUFFER_SELECTOR), | ||
hasClass: (className) => this.root_.classList.contains(className), | ||
removeClass: (className) => this.root_.classList.remove(className), | ||
setStyle: (el, styleProperty, value) => el.style[styleProperty] = value, | ||
getPrimaryBar: () => this.root_.querySelector(MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR), | ||
hasClass: (className: string) => this.root_.classList.contains(className), | ||
removeClass: (className: string) => this.root_.classList.remove(className), | ||
setStyle: (el: HTMLElement, styleProperty: string, value: string) => el.style.setProperty(styleProperty, value), | ||
}); | ||
} | ||
} |
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
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
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.