Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-27164] Picture Selector Common Component #5973

Merged
merged 51 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6308348
WIP
devinbinnie Jun 25, 2020
a2450a8
WIP
devinbinnie Jun 30, 2020
d2bdbac
Merge remote-tracking branch 'upstream/master' into MM-26465
devinbinnie Jun 30, 2020
6f376e3
[MM-26465] Background and general layout for cloud onboarding
devinbinnie Jun 30, 2020
776823e
Mobile view, lint and type fixes, added a test file for later use
devinbinnie Jun 30, 2020
630cc19
More test fixes
devinbinnie Jun 30, 2020
afa668e
UX feedback
devinbinnie Jul 2, 2020
7f57467
Replaced dumb comment with useful one
devinbinnie Jul 3, 2020
05521d8
Turn off graphic at 1020px
devinbinnie Jul 3, 2020
b7d78f1
WIP
devinbinnie Jul 2, 2020
88df376
Initial card style
devinbinnie Jul 2, 2020
b8e7ea8
Collapse functionality (no animation)
devinbinnie Jul 2, 2020
d62b7ef
WIP
devinbinnie Jul 3, 2020
6b16a03
Rest of accordion common component and some animation
devinbinnie Jul 6, 2020
60ad53a
Lint, type and test fixes
devinbinnie Jul 6, 2020
d56417c
Updated snapshot
devinbinnie Jul 7, 2020
0027735
Reduce nesting
devinbinnie Jul 7, 2020
839f962
WIP - Wiring for step wizard
devinbinnie Jul 8, 2020
e6e10cd
Skip getting started link, hook for final page
devinbinnie Jul 9, 2020
7376698
Moved steps into its own constants file, type and test fixes
devinbinnie Jul 9, 2020
c604880
Shifted around the screen changing and added final screen placeholder
devinbinnie Jul 9, 2020
b2dc9c3
Translations and wizard navigation button styling
devinbinnie Jul 10, 2020
6d4aaef
Pick starting step based on which are finished, button styling fixes
devinbinnie Jul 10, 2020
d140a63
Allow for getting out of next steps view by switching channels
devinbinnie Jul 10, 2020
c63851c
PR feedback
devinbinnie Jul 13, 2020
ba4f642
PR feedback
devinbinnie Jul 15, 2020
677dfd2
blank
devinbinnie Jul 15, 2020
e47ddf4
Change style of complete card header to be more like the regular one
devinbinnie Jul 16, 2020
70dce26
Fixed background on complete step
devinbinnie Jul 16, 2020
58fcc44
Merge branch 'feature/cloud-onboarding' into MM-26470
devinbinnie Jul 16, 2020
98628b1
Merge'd
devinbinnie Jul 16, 2020
202f215
PR feedback
devinbinnie Jul 16, 2020
2904373
PR feedback
devinbinnie Jul 16, 2020
f429567
Removed translation
devinbinnie Jul 16, 2020
1d8c6c0
Fixed box shadow transition on card
devinbinnie Jul 21, 2020
0c856a5
Removed duplicate logic
devinbinnie Jul 21, 2020
8615269
WIP
devinbinnie Jul 21, 2020
05bfd36
Functional component that works
devinbinnie Jul 22, 2020
7e2e31a
Styling and a couple tweaks
devinbinnie Jul 22, 2020
b76aacb
A few tests
devinbinnie Jul 22, 2020
9ba4b80
Snapshots
devinbinnie Jul 22, 2020
9e3507c
Type and i18n fixes
devinbinnie Jul 23, 2020
cb02d04
PR feedback and test fixes
devinbinnie Jul 23, 2020
3b49a13
Merge branch 'MM-27164' of https://github.com/devinbinnie/mattermost-…
devinbinnie Jul 23, 2020
999d90e
Merge branch 'feature/cloud-onboarding' into MM-27164
devinbinnie Jul 23, 2020
4e81a1b
Added button hover states
devinbinnie Jul 27, 2020
9eb0fcc
PR feedback
devinbinnie Jul 27, 2020
44600dd
Blur select button on select image
devinbinnie Jul 27, 2020
bdf625d
Blur on click, not on select image
devinbinnie Jul 28, 2020
c78b9cb
Update components/picture_selector.tsx
devinbinnie Jul 28, 2020
9896a18
Merge branch 'feature/cloud-onboarding' into MM-27164
devinbinnie Jul 30, 2020
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
118 changes: 118 additions & 0 deletions components/__snapshots__/picture_selector.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`components/picture_selector should match snapshot, default picture provided 1`] = `
<div
className="PictureSelector"
>
<input
accept=".jpg,.png,.bmp"
aria-hidden={true}
className="PictureSelector__input"
data-testid="PictureSelector__input"
onChange={[Function]}
tabIndex={-1}
type="file"
/>
<div
className="PictureSelector__imageContainer"
>
<div
aria-label="Picture selector image"
className="PictureSelector__image"
style={
Object {
"backgroundImage": "url(undefined)",
}
}
/>
<button
aria-label="Select picture"
className="PictureSelector__selectButton"
data-testid="PictureSelector__selectButton"
onClick={[Function]}
>
<i
className="icon icon-pencil-outline"
/>
</button>
</div>
</div>
`;

exports[`components/picture_selector should match snapshot, existing picture provided 1`] = `
<div
className="PictureSelector"
>
<input
accept=".jpg,.png,.bmp"
aria-hidden={true}
className="PictureSelector__input"
data-testid="PictureSelector__input"
onChange={[Function]}
tabIndex={-1}
type="file"
/>
<div
className="PictureSelector__imageContainer"
>
<div
aria-label="Picture selector image"
className="PictureSelector__image"
style={
Object {
"backgroundImage": "url(undefined)",
}
}
/>
<button
aria-label="Select picture"
className="PictureSelector__selectButton"
data-testid="PictureSelector__selectButton"
onClick={[Function]}
>
<i
className="icon icon-pencil-outline"
/>
</button>
</div>
</div>
`;

exports[`components/picture_selector should match snapshot, no picture selected 1`] = `
<div
className="PictureSelector"
>
<input
accept=".jpg,.png,.bmp"
aria-hidden={true}
className="PictureSelector__input"
data-testid="PictureSelector__input"
onChange={[Function]}
tabIndex={-1}
type="file"
/>
<div
className="PictureSelector__imageContainer"
>
<div
aria-label="Picture selector image"
className="PictureSelector__image"
style={
Object {
"backgroundImage": "url(undefined)",
}
}
/>
<button
aria-label="Select picture"
className="PictureSelector__selectButton"
data-testid="PictureSelector__selectButton"
onClick={[Function]}
>
<i
className="icon icon-pencil-outline"
/>
</button>
</div>
</div>
`;
15 changes: 11 additions & 4 deletions components/card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.08);
border-radius: 4px;
background-color: var(--center-channel-bg);
transition: box-shadow 0.3s ease-in-out;

& + .Card {
margin-top: 16px;
Expand All @@ -16,7 +17,7 @@
.Card__header {
margin: 12px 12px 0 12px;
padding-bottom: 12px;

&.expanded {
border-bottom: 1px solid rgba(var(--center-channel-color-rgb), 0.08);
}
Expand All @@ -31,7 +32,13 @@
transition-timing-function: ease-in-out;
transition-property: height, margin;

&.expanded {
margin: 12px;
&.expanded {
margin: 12px;
}
}

@media screen and (max-width: 768px) {
.Card + .Card {
margin-top: 12px;
}
}
}
5 changes: 3 additions & 2 deletions components/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import './card.scss';

type Props = {
expanded?: boolean;
className?: string;
}

export default class Card extends React.PureComponent<Props> {
Expand All @@ -30,12 +31,12 @@ export default class Card extends React.PureComponent<Props> {

return (
<div
className={classNames('Card', {
className={classNames(`Card${this.props.className ? ` ${this.props.className}` : ''}`, {
expanded,
})}
>
{childrenWithProps}
</div>
);
}
}
}
2 changes: 1 addition & 1 deletion components/card/card_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class CardBody extends React.PureComponent<Props> {

if (this.props.expanded !== prevProps.expanded && this.props.expanded) {
this.card.current.style.height = `${this.card.current.scrollHeight}px`;
} else {
} else if (!this.props.expanded) {
this.card.current.style.height = '';
}
}
Expand Down
5 changes: 3 additions & 2 deletions components/channel_view/channel_view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class ChannelView extends React.PureComponent {
const focusedPostId = props.match.params.postid;

if (props.match.url !== state.url && props.channelId !== state.channelId) {
updatedState = {deferredPostView: ChannelView.createDeferredPostView(), url: props.match.url, focusedPostId};
updatedState = {deferredPostView: ChannelView.createDeferredPostView(), url: props.match.url, focusedPostId, showNextSteps: false};
}

if (props.channelId !== state.channelId) {
Expand All @@ -79,6 +79,7 @@ export default class ChannelView extends React.PureComponent {
url: props.match.url,
channelId: props.channelId,
deferredPostView: ChannelView.createDeferredPostView(),
showNextSteps: props.showNextSteps,
};
}

Expand Down Expand Up @@ -125,7 +126,7 @@ export default class ChannelView extends React.PureComponent {
);
}

if (this.props.showNextSteps) {
if (this.state.showNextSteps) {
return (
<NextStepsView/>
);
Expand Down
3 changes: 2 additions & 1 deletion components/channel_view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {getDirectTeammate} from 'utils/utils.jsx';
import {TutorialSteps, Preferences} from 'utils/constants';

import {goToLastViewedChannel} from 'actions/views/channel';
import {showNextSteps} from 'components/next_steps_view/steps';

import ChannelView from './channel_view.jsx';

Expand Down Expand Up @@ -57,7 +58,7 @@ function mapStateToProps(state) {
channelRolesLoading,
deactivatedChannel: channel ? getDeactivatedChannel(state, channel.id) : false,
showTutorial: enableTutorial && tutorialStep <= TutorialSteps.INTRO_SCREENS,
showNextSteps: true,
showNextSteps: showNextSteps(state),
channelIsArchived: channel ? channel.delete_at !== 0 : false,
viewArchivedChannels,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,23 @@ exports[`components/next_steps_view should match snapshot 1`] = `
className="NextStepsView__body-main"
>
<Accordion
defaultExpandedKey="Card_1"
defaultExpandedKey="complete_profile"
>
<Component />
</Accordion>
<div
className="NextStepsView__skipGettingStarted"
>
<button
onClick={[Function]}
>
<FormattedMessage
defaultMessage="Skip Getting Started"
id="next_steps_view.skipGettingStarted"
values={Object {}}
/>
</button>
</div>
</div>
<div
className="NextStepsView__body-graphic"
Expand Down
24 changes: 16 additions & 8 deletions components/next_steps_view/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {connect} from 'react-redux';
import {bindActionCreators, Dispatch} from 'redux';

import {savePreferences} from 'mattermost-redux/actions/preferences';
import {getLicense} from 'mattermost-redux/selectors/entities/general';
import {makeGetCategory} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';

import {GlobalState} from 'types/store';
import {Preferences} from 'utils/constants';

import NextStepsView from './next_steps_view';

function mapStateToProps(state: GlobalState) {
const license = getLicense(state);
function makeMapStateToProps() {
const getCategory = makeGetCategory();

return {
skuName: license.SkuShortName,
return (state: GlobalState) => {
const license = getLicense(state);

return {
currentUser: getCurrentUser(state),
preferences: getCategory(state, Preferences.RECOMMENDED_NEXT_STEPS),
skuName: license.SkuShortName,
};
};
}

function mapDispatchToProps(dispatch: Dispatch) {
return {
actions: bindActionCreators({
savePreferences,
}, dispatch),
};
}

export default connect(mapStateToProps, mapDispatchToProps)(NextStepsView);
export default connect(makeMapStateToProps, mapDispatchToProps)(NextStepsView);
Loading