Apply some styles
Summary: It looks a lot better now, but the input is only single line, so entering more than one line would not be good right now. Reviewed By: danielbuechele Differential Revision: D17210091 fbshipit-source-id: 9313b6a67731cfa944394962cdc09be915a07720
This commit is contained in:
committed by
Facebook Github Bot
parent
be22cc711a
commit
8fff3fcf59
@@ -6,7 +6,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React, {Component, ReactElement} from 'react';
|
import React, {Component, ReactElement} from 'react';
|
||||||
import {Glyph, Popover, FlexColumn, FlexRow, Button, Checkbox} from 'flipper';
|
import {
|
||||||
|
Glyph,
|
||||||
|
Popover,
|
||||||
|
FlexColumn,
|
||||||
|
FlexRow,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
styled,
|
||||||
|
Input,
|
||||||
|
} from 'flipper';
|
||||||
import GK from '../fb-stubs/GK';
|
import GK from '../fb-stubs/GK';
|
||||||
import * as UserFeedback from '../fb-stubs/UserFeedback';
|
import * as UserFeedback from '../fb-stubs/UserFeedback';
|
||||||
import {FeedbackPrompt} from '../fb-stubs/UserFeedback';
|
import {FeedbackPrompt} from '../fb-stubs/UserFeedback';
|
||||||
@@ -36,6 +45,14 @@ class PredefinedComment extends Component<{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Row = styled(FlexRow)({
|
||||||
|
marginTop: 5,
|
||||||
|
marginBottom: 5,
|
||||||
|
justifyContent: 'center',
|
||||||
|
textAlign: 'center',
|
||||||
|
color: '#9a9a9a',
|
||||||
|
});
|
||||||
|
|
||||||
class FeedbackComponent extends Component<
|
class FeedbackComponent extends Component<
|
||||||
{
|
{
|
||||||
submitRating: (rating: number) => void;
|
submitRating: (rating: number) => void;
|
||||||
@@ -54,6 +71,7 @@ class FeedbackComponent extends Component<
|
|||||||
allowUserInfoSharing: boolean;
|
allowUserInfoSharing: boolean;
|
||||||
nextAction: NextAction;
|
nextAction: NextAction;
|
||||||
predefinedComments: {[key: string]: boolean};
|
predefinedComments: {[key: string]: boolean};
|
||||||
|
comment: string;
|
||||||
}
|
}
|
||||||
> {
|
> {
|
||||||
state = {
|
state = {
|
||||||
@@ -65,6 +83,7 @@ class FeedbackComponent extends Component<
|
|||||||
(acc, cv) => ({...acc, [cv]: false}),
|
(acc, cv) => ({...acc, [cv]: false}),
|
||||||
{},
|
{},
|
||||||
),
|
),
|
||||||
|
comment: '',
|
||||||
};
|
};
|
||||||
onSubmitRating(newRating: number) {
|
onSubmitRating(newRating: number) {
|
||||||
const nextAction = newRating <= 2 ? 'leave-comment' : 'finished';
|
const nextAction = newRating <= 2 ? 'leave-comment' : 'finished';
|
||||||
@@ -116,15 +135,15 @@ class FeedbackComponent extends Component<
|
|||||||
this.onSubmitRating(index + 1);
|
this.onSubmitRating(index + 1);
|
||||||
}}>
|
}}>
|
||||||
<Glyph
|
<Glyph
|
||||||
name="star"
|
name={
|
||||||
color="grey"
|
|
||||||
variant={
|
|
||||||
(this.state.hoveredRating
|
(this.state.hoveredRating
|
||||||
? index < this.state.hoveredRating
|
? index < this.state.hoveredRating
|
||||||
: index < (this.state.rating || 0))
|
: index < (this.state.rating || 0))
|
||||||
? 'filled'
|
? 'star'
|
||||||
: 'outline'
|
: 'star-outline'
|
||||||
}
|
}
|
||||||
|
color="grey"
|
||||||
|
size={24}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
@@ -132,8 +151,8 @@ class FeedbackComponent extends Component<
|
|||||||
switch (this.state.nextAction) {
|
switch (this.state.nextAction) {
|
||||||
case 'select-rating':
|
case 'select-rating':
|
||||||
body = [
|
body = [
|
||||||
<FlexRow>{this.props.promptData.bodyText}</FlexRow>,
|
<Row>{this.props.promptData.bodyText}</Row>,
|
||||||
<FlexRow>{stars}</FlexRow>,
|
<Row style={{margin: 'auto'}}>{stars}</Row>,
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 'leave-comment':
|
case 'leave-comment':
|
||||||
@@ -154,18 +173,27 @@ class FeedbackComponent extends Component<
|
|||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
body = [
|
body = [
|
||||||
<FlexRow>{predefinedComments}</FlexRow>,
|
<Row>{predefinedComments}</Row>,
|
||||||
<FlexRow>{this.props.promptData.commentPlaceholder}</FlexRow>,
|
<Row>
|
||||||
<FlexRow>
|
<Input
|
||||||
|
style={{height: 30, width: '100%'}}
|
||||||
|
placeholder={this.props.promptData.commentPlaceholder}
|
||||||
|
value={this.state.comment}
|
||||||
|
onChange={e => this.setState({comment: e.target.value})}
|
||||||
|
/>
|
||||||
|
</Row>,
|
||||||
|
<Row>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={this.state.allowUserInfoSharing}
|
checked={this.state.allowUserInfoSharing}
|
||||||
onChange={this.onAllowUserSharingChanged.bind(this)}
|
onChange={this.onAllowUserSharingChanged.bind(this)}
|
||||||
/>
|
/>
|
||||||
{'Tool owner can contact me '}
|
{'Tool owner can contact me '}
|
||||||
<Button onClick={() => this.onCommentSubmitted('some comment')}>
|
</Row>,
|
||||||
|
<Row>
|
||||||
|
<Button onClick={() => this.onCommentSubmitted(this.state.comment)}>
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
</FlexRow>,
|
</Row>,
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 'finished':
|
case 'finished':
|
||||||
@@ -177,12 +205,19 @@ class FeedbackComponent extends Component<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<FlexColumn>
|
<FlexColumn
|
||||||
<FlexRow>
|
style={{
|
||||||
|
width: 400,
|
||||||
|
paddingLeft: 20,
|
||||||
|
paddingRight: 20,
|
||||||
|
paddingTop: 10,
|
||||||
|
paddingBottom: 10,
|
||||||
|
}}>
|
||||||
|
<Row style={{color: 'black', fontSize: 20}}>
|
||||||
{this.state.nextAction === 'finished'
|
{this.state.nextAction === 'finished'
|
||||||
? this.props.promptData.postSubmitHeading
|
? this.props.promptData.postSubmitHeading
|
||||||
: this.props.promptData.preSubmitHeading}
|
: this.props.promptData.preSubmitHeading}
|
||||||
</FlexRow>
|
</Row>
|
||||||
{body}
|
{body}
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
);
|
);
|
||||||
@@ -232,7 +267,8 @@ export default class RatingButton extends Component<Props, State> {
|
|||||||
if (!promptData) {
|
if (!promptData) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const stars = (
|
return (
|
||||||
|
<div style={{position: 'relative'}}>
|
||||||
<div onClick={this.onClick.bind(this)}>
|
<div onClick={this.onClick.bind(this)}>
|
||||||
<Glyph
|
<Glyph
|
||||||
name="star"
|
name="star"
|
||||||
@@ -240,10 +276,7 @@ export default class RatingButton extends Component<Props, State> {
|
|||||||
variant={this.state.isShown ? 'filled' : 'outline'}
|
variant={this.state.isShown ? 'filled' : 'outline'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
{this.state.isShown ? (
|
||||||
return [
|
|
||||||
stars,
|
|
||||||
this.state.isShown ? (
|
|
||||||
<Popover
|
<Popover
|
||||||
onDismiss={() => {}}
|
onDismiss={() => {}}
|
||||||
children={
|
children={
|
||||||
@@ -257,7 +290,8 @@ export default class RatingButton extends Component<Props, State> {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : null,
|
) : null}
|
||||||
];
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ module.exports = {
|
|||||||
'triangle-right': [12],
|
'triangle-right': [12],
|
||||||
'chevron-right': [8],
|
'chevron-right': [8],
|
||||||
'chevron-down': [8],
|
'chevron-down': [8],
|
||||||
star: [16],
|
star: [16, 24],
|
||||||
'star-outline': [16],
|
'star-outline': [16, 24],
|
||||||
},
|
},
|
||||||
|
|
||||||
// $FlowFixMe: not using flow in this file
|
// $FlowFixMe: not using flow in this file
|
||||||
|
|||||||
Reference in New Issue
Block a user