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

Styles for all basic form components #135

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
319 changes: 178 additions & 141 deletions demo/content/Form.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/Form/Checkbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ class Checkbox extends Component {
}

const primaryColor = this.context.OIOStyles.primaryColor
let checkboxIcon = 'ion-ios-circle-outline'
let checkboxIcon = 'ion-android-checkbox-outline-blank'
let checkboxIconStyle = {}

if (this.state.checked) {
checkboxIcon = 'ion-ios-checkmark'
checkboxIcon = 'ion-android-checkbox'
checkboxIconStyle = {
color: primaryColor
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/Checkbox/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
opacity: 0;
}
span {
color: #888;
color: #A8A8A8;
}
}
23 changes: 19 additions & 4 deletions src/components/Form/Input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ class Input extends Component {
id: PropTypes.string,
initialValue: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
label: PropTypes.string,
description: PropTypes.string,
name: PropTypes.string.isRequired,
oioFormContext: PropTypes.object.isRequired,
onBlur: PropTypes.func,
onChange: PropTypes.func,
placeholder: PropTypes.string,
type: PropTypes.string,
readOnly: PropTypes.bool,
required: PropTypes.bool,
value: PropTypes.string
}

static defaultProps = {
// error: 'required ',
required: true,
type: 'text'
}

Expand All @@ -47,7 +51,7 @@ class Input extends Component {

if (typeof nextProps.initialValue !== 'undefined') {
if (nextProps.initialValue !== prevState.initialValue) {
nextProps.oioFormContext.setInitialValue(nextProps.name, nextProps.initialValue)
// nextProps.oioFormContext.setInitialValue(nextProps.name, nextProps.initialValue)
return {
controlled,
initialValue: nextProps.initialValue,
Expand All @@ -56,7 +60,7 @@ class Input extends Component {
}
// Default
} else if (typeof prevState.value === 'undefined') {
nextProps.oioFormContext.setInitialValue(nextProps.name, '')
// nextProps.oioFormContext.setInitialValue(nextProps.name, '')
return {
controlled,
initialValue: '',
Expand Down Expand Up @@ -92,7 +96,7 @@ class Input extends Component {
}

render() {
const classes = [styles.input, this.props.className]
const classes = [styles.input, this.props.className, this.props.error && styles.error]
const inputStyles = {}

if (this.context.OIOStyles && this.context.OIOStyles.fontFamily) {
Expand All @@ -101,7 +105,17 @@ class Input extends Component {

return (
<div className={formStyles.container}>
{this.props.label && <label htmlFor={this.props.id}>{this.props.label}</label>}
<div className={formStyles.lab}>
{this.props.label && (
<label htmlFor={this.props.id}>
{this.props.label}
{this.props.required && <div style={{ color: 'red', display: 'inline' }}> *</div>}
</label>
)}
{this.props.description
&& <div className={formStyles.description}>{this.props.description}</div>}
</div>

<input
id={this.props.id}
style={inputStyles}
Expand All @@ -114,6 +128,7 @@ class Input extends Component {
type={this.props.type}
value={this.state.controlled ? this.props.value : this.state.value}
/>

{this.props.error && (
<div className={formStyles.error}>
{this.props.error}
Expand Down
21 changes: 17 additions & 4 deletions src/components/Form/Input/styles.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@import '../../../foundation/mixins';

@uiBaseBorderColor2: #DFDFDF;
@uiBasePlaceholderColor: #A8A8A8;
@uiBaseDescription: #454545;

.input {
color: rgba(0, 0, 0, 0.87);
-webkit-appearance: none;
margin: 0;
background: none;
Expand All @@ -11,12 +16,20 @@
//.rounded(@uiBaseComponentRadius);
.uiTextSize3;
line-height: @uiBaseComponentHeightMedium - 13px;
padding: 5px 0px 5px 0px;
padding: 10px 10px 10px 10px;
.transition(300ms);
//border: none;
border-bottom: 2px solid @uiBaseBorderColor;
border: 1px solid @uiBaseBorderColor2;
border-radius: 3px;

&:focus {border: 1px solid #aaa;}

&:focus {
border-bottom: 2px solid #aaa;
&.error {
background-color: #FFF7F7;
border: 1px solid #DD3300;
}
}

input::placeholder {
color: @uiBasePlaceholderColor;
}
4 changes: 2 additions & 2 deletions src/components/Form/Radio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ class Radio extends Component {
}

const primaryColor = this.context.OIOStyles.primaryColor
let radioIcon = 'ion-ios-circle-outline'
let radioIcon = 'ion-android-radio-button-off'
let radioIconStyle = {}

if (checked) {
radioIcon = 'ion-ios-circle-filled'
radioIcon = 'ion-android-radio-button-on'
radioIconStyle = {
color: primaryColor
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/Radio/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
opacity: 0;
}
span {
color: #888;
color: #A8A8A8;
}
}
22 changes: 19 additions & 3 deletions src/components/Form/Select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ class Select extends Component {
id: PropTypes.string,
initialValue: PropTypes.string,
label: PropTypes.string,
description: PropTypes.string,
name: PropTypes.string.isRequired,
oioFormContext: PropTypes.object.isRequired,
onBlur: PropTypes.func,
onChange: PropTypes.func,
options: PropTypes.array,
readOnly: PropTypes.bool,
required: PropTypes.bool,
value: PropTypes.string
}

static defaultProps = {
options: []
options: [],
required: false
}

static getDerivedStateFromProps(nextProps, prevState) {
Expand Down Expand Up @@ -85,7 +88,7 @@ class Select extends Component {
}

render() {
const classes = [styles.select, this.props.className]
const classes = [styles.select, this.props.className, this.props.error && styles.error]
const options = this.props.options.map(option => (
<option
key={option.value}
Expand All @@ -97,7 +100,20 @@ class Select extends Component {

return (
<div className={formStyles.container}>
{this.props.label && <label htmlFor={this.props.id}>{this.props.label}</label>}
<div className={formStyles.lab}>
{this.props.label && (
<label htmlFor={this.props.id}>
{this.props.label}
{this.props.required && <div style={{ color: 'red', display: 'inline' }}> *</div>}
</label>
)}
{this.props.description && (
<div
className={formStyles.description}>
{this.props.description}
</div>
)}
</div>
<select
className={classNames(classes)}
id={this.props.id}
Expand Down
19 changes: 16 additions & 3 deletions src/components/Form/Select/styles.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@import '../../../foundation/mixins';

@uiBaseBorderColor2: #DFDFDF;
@uiBasePlaceholderColor: #A8A8A8;

.select {
color: @uiBasePlaceholderColor;
-webkit-appearance: none;
margin: 0;
background: none;
Expand All @@ -13,12 +17,21 @@
line-height: @uiBaseComponentHeightMedium - 13px;
padding: 5px 10px 5px 10px;
.transition(300ms);
border: 2px solid @uiBaseBorderColor;
background-position: 98% 50%;
border: 1px solid @uiBaseBorderColor2;
background-position: 99% 50%;
background-repeat: no-repeat;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAABaBAMAAABd1/vrAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGo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AAElFTkSuQmCC');

&:focus {
border: 2px solid #aaa;
border: 1px solid #aaa;
}

&.error {
background-color: #FFF7F7;
border: 1px solid #DD3300;
}

option:disabled {
color: red;
}
}
20 changes: 18 additions & 2 deletions src/components/Form/Textarea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ class Textarea extends Component {
error: PropTypes.string,
id: PropTypes.string,
label: PropTypes.string,
description: PropTypes.string,
name: PropTypes.string,
oioFormContext: PropTypes.object.isRequired,
onBlur: PropTypes.func,
placeholder: PropTypes.string,
readOnly: PropTypes.bool,
required: PropTypes.bool,
rows: PropTypes.string,
onChange: PropTypes.func,
value: PropTypes.string
}

static defaultProps = {
required: false,
disabled: false,
rows: '5'
}
Expand Down Expand Up @@ -89,11 +92,24 @@ class Textarea extends Component {
}

render() {
const classes = [styles.textarea, this.props.className]
const classes = [styles.textarea, this.props.className, this.props.error && styles.error]

return (
<div className={formStyles.container}>
{this.props.label && <label htmlFor={this.props.id}>{this.props.label}</label>}
<div className={formStyles.lab}>
{this.props.label && (
<label htmlFor={this.props.id}>
{this.props.label}
{this.props.required && <div style={{ color: 'red', display: 'inline' }}> *</div>}
</label>
)}
{this.props.description && (
<div
className={formStyles.description}>
{this.props.description}
</div>
)}
</div>
<textarea
className={classNames(classes)}
disabled={this.props.disabled}
Expand Down
18 changes: 15 additions & 3 deletions src/components/Form/Textarea/styles.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@import '../../../foundation/mixins';

@uiBaseBorderColor2: #DFDFDF;
@uiBasePlaceholderColor: #A8A8A8;

.textarea {
-webkit-appearance: none;
margin: 0;
Expand All @@ -9,10 +12,19 @@
width: 100%;
.rounded(@uiBaseComponentRadius);
.uiTextSize3;
padding: 5px 10px;
padding: 10px 10px;
.transition(300ms);
border: 2px solid @uiBaseBorderColor;
border: 1px solid @uiBaseBorderColor2;

&:focus { border: 2px solid #aaa; }
&:focus { border: 1px solid #aaa; }
&:disabled { opacity: 0.5; }

&.error {
background-color: #FFF7F7;
border: 1px solid #DD3300;
}
}

.textarea::placeholder {
color: @uiBasePlaceholderColor;
}
Loading