This repository has been archived by the owner on Jun 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Initial commit of component render classes. #8
Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0638019
Initial commit of component render classes.
chriscox e5d96a8
Merge branch 'develop' into feature/components
chriscox 8500f7e
First pass of updates per feedback.
chriscox dad1c8b
Another pass of updates per feedback.
chriscox 3c4c4fe
Refactors components to controls using Composition rather than Inheri…
chriscox 2a0e894
Finalizes refactor of components to controls using Composition rather…
chriscox 6bc9a3e
Updates constants formatting.
chriscox db0fa11
Fixes styles.less spacing/tabs.
chriscox 939dbf7
Adds class commenting. Adds missing TextFieldControl. Removes SliderC…
chriscox f5d12f7
Merge branch 'develop' into feature/components
chriscox 9ff18a0
Cleans up a few comment and strings.
chriscox 2840c31
Updates control interfaces.
chriscox 9bde50b
Refactors variable controls to call a prop callback method when updated.
chriscox be4a5d8
Work-in-progress.
chriscox bef5a8e
Now clones variables during update, allowing each control to handle i…
chriscox 5d548ad
Resets package.json.
chriscox f791971
Merge branch 'develop' into feature/components
chriscox 95e2423
Adds a render.tsx with logic that handles redrawing when variables up…
chriscox fffa746
Fixes adding callbacks to internal _callbacks
chriscox e1ea4fc
Minor code cleanup.
chriscox 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 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 |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
*/ | ||
|
||
import * as React from "react"; | ||
import { ColorControlInterface } from "./controlInterfaces"; | ||
import { ColorVariable } from "../../core/variables/ColorVariable"; | ||
import { ControlInterface } from "./ControlInterface"; | ||
import { CSS, VariableType } from "../../lib/Constants"; | ||
|
||
/** | ||
|
@@ -30,20 +30,17 @@ interface ColorSwatchProps { | |
} | ||
|
||
/** | ||
* A single color swatch displayed within the `ColorSwatchControl`. | ||
* @class | ||
* @extends React.Component | ||
* Returns a single color swatch displayed within the `ColorSwatchControl`. | ||
* @param {ColorSwatchProps} props The color swath properties. | ||
*/ | ||
class ColorSwatch extends React.Component<ColorSwatchProps, void> { | ||
render() { | ||
const { color, isSelected, onClick } = this.props; | ||
return ( | ||
<div className={CSS.RMX_COLOR_SWATCH_ITEM} style={{backgroundColor: color}} | ||
value={color} onClick={onClick}> | ||
{isSelected ? <i className="material-icons">check</i> : ""} | ||
</div> | ||
); | ||
} | ||
function ColorSwatch(props: ColorSwatchProps) { | ||
const { color, isSelected, onClick } = props; | ||
return ( | ||
<div className={CSS.RMX_COLOR_SWATCH_ITEM} style={{backgroundColor: color}} | ||
value={color} onClick={onClick}> | ||
{isSelected ? <i className="material-icons">check</i> : ""} | ||
</div> | ||
); | ||
} | ||
|
||
/** | ||
|
@@ -52,7 +49,7 @@ class ColorSwatch extends React.Component<ColorSwatchProps, void> { | |
* @class | ||
* @extends React.Component | ||
*/ | ||
export class ColorSwatchControl extends React.Component<ControlInterface, ControlInterface> { | ||
export class ColorSwatchControl extends React.Component<ColorControlInterface, ColorControlInterface> { | ||
state = { | ||
variable: this.props.variable, | ||
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. Why are you storing a prop as state? Seems like you could get rid of all the state entirely and just move the |
||
}; | ||
|
@@ -63,7 +60,7 @@ export class ColorSwatchControl extends React.Component<ControlInterface, Contro | |
const { | ||
possibleValues, | ||
selectedValue | ||
} = this.state.variable as ColorVariable; | ||
} = this.state.variable; | ||
|
||
if (possibleValues.indexOf(selectedValue) === -1) { | ||
possibleValues.push(selectedValue); | ||
|
@@ -87,7 +84,7 @@ export class ColorSwatchControl extends React.Component<ControlInterface, Contro | |
title, | ||
possibleValues, | ||
selectedValue | ||
} = this.state.variable as ColorVariable; | ||
} = this.state.variable; | ||
|
||
return ( | ||
<div className={`${CSS.RMX_COLOR_SWATCH} ${CSS.MDL_LIST_ITEM} ${CSS.MDL_TWO_LINE}`}> | ||
|
This file was deleted.
Oops, something went wrong.
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
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
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,80 @@ | ||
/** @license | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { BooleanVariable } from "../../core/variables/BooleanVariable"; | ||
import { ColorVariable } from "../../core/variables/ColorVariable"; | ||
import { NumberVariable } from "../../core/variables/NumberVariable"; | ||
import { RangeVariable } from "../../core/variables/RangeVariable"; | ||
import { StringVariable } from "../../core/variables/StringVariable"; | ||
import { Variable } from "../../core/variables/Variable"; | ||
|
||
/** | ||
* Interface for variable controls properties and state. | ||
* @interface | ||
*/ | ||
interface ControlInterface { | ||
variable: Variable; | ||
} | ||
|
||
/** | ||
* Interface for the properties and state of a control that implements a | ||
* Boolean variable. | ||
* @interface | ||
* @extends ControlInterface | ||
*/ | ||
export interface BooleanControlInterface extends ControlInterface { | ||
variable: BooleanVariable; | ||
} | ||
|
||
/** | ||
* Interface for the properties and state of a control that implements a | ||
* Color variable. | ||
* @interface | ||
* @extends ControlInterface | ||
*/ | ||
export interface ColorControlInterface extends ControlInterface { | ||
variable: ColorVariable; | ||
} | ||
|
||
/** | ||
* Interface for the properties and state of a control that implements a | ||
* Number variable. | ||
* @interface | ||
* @extends ControlInterface | ||
*/ | ||
export interface NumberControlInterface extends ControlInterface { | ||
variable: NumberVariable; | ||
} | ||
|
||
/** | ||
* Interface for the properties and state of a control that implements a | ||
* Range variable. | ||
* @interface | ||
* @extends ControlInterface | ||
*/ | ||
export interface RangeControlInterface extends ControlInterface { | ||
variable: RangeVariable; | ||
} | ||
|
||
/** | ||
* Interface for the properties and state of a control that implements a | ||
* String variable. | ||
* @interface | ||
* @extends ControlInterface | ||
*/ | ||
export interface StringControlInterface extends ControlInterface { | ||
variable: StringVariable; | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"swatch"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done