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

Feature/avatar edit action #406

Merged
merged 5 commits into from
Oct 21, 2021
Merged
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
1 change: 0 additions & 1 deletion packages/asc-web-components/avatar/avatar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ Default.args = {
source: "",
userName: "",
editing: false,
editLabel: "Edit photo",
};
38 changes: 9 additions & 29 deletions packages/asc-web-components/avatar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import styled from "styled-components";

import { GuestIcon, AdministratorIcon, OwnerIcon } from "./svg";
import {
EditLink,
EmptyIcon,
EditContainer,
AvatarWrapper,
Expand All @@ -13,7 +12,7 @@ import {
StyledImage,
StyledAvatar,
} from "./styled-avatar";
import Link from "../link";
import IconButton from "../icon-button";
import commonIconsStyles from "../utils/common-icons-style";

const whiteColor = "#FFFFFF";
Expand Down Expand Up @@ -57,15 +56,7 @@ Initials.propTypes = {
// eslint-disable-next-line react/display-name
const Avatar = (props) => {
//console.log("Avatar render");
const {
size,
source,
userName,
role,
editing,
editLabel,
editAction,
} = props;
const { size, source, userName, role, editing, editAction } = props;

const avatarContent = source ? (
<StyledImage src={source} />
Expand All @@ -83,21 +74,13 @@ const Avatar = (props) => {
{avatarContent}
</AvatarWrapper>
{editing && size === "max" && (
<EditContainer gradient={!!source}>
<EditLink>
<Link
type="action"
title={editLabel}
isTextOverflow={true}
isHovered={true}
fontSize="14px"
fontWeight={600}
color={whiteColor}
onClick={editAction}
>
{editLabel}
</Link>
</EditLink>
<EditContainer>
<IconButton
color={whiteColor}
iconName="/static/images/pencil.react.svg"
onClick={editAction}
size={16}
/>
</EditContainer>
)}
<RoleWrapper size={size}>{roleIcon}</RoleWrapper>
Expand All @@ -112,8 +95,6 @@ Avatar.propTypes = {
role: PropTypes.oneOf(["owner", "admin", "guest", "user"]),
/** The address of the image for an image avatar */
source: PropTypes.string,
/** Displays avatar edit layer */
editLabel: PropTypes.string,
userName: PropTypes.string,
editing: PropTypes.bool,
/** Function called when the avatar change button is pressed */
Expand All @@ -130,7 +111,6 @@ Avatar.defaultProps = {
size: "medium",
role: "",
source: "",
editLabel: "Edit photo",
userName: "",
editing: false,
};
Expand Down
40 changes: 9 additions & 31 deletions packages/asc-web-components/avatar/styled-avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,24 @@ import NoUserSelect from "../utils/commonStyles";
import { CameraIcon } from "./svg";
import commonIconsStyles from "../utils/common-icons-style";


const EditLink = styled.div`
padding-left: ${(props) => props.theme.avatar.editLink.paddingLeft};
padding-right: ${(props) => props.theme.avatar.editLink.paddingRight};

a:hover {
border-bottom: ${(props) => props.theme.avatar.editLink.borderBottom};
}

span {
display: ${(props) => props.theme.avatar.editLink.display};
max-width: ${(props) => props.theme.avatar.editLink.maxWidth};
text-decoration: ${(props) => props.theme.avatar.editLink.textDecoration};
}
`;
EditLink.defaultProps = { theme: Base };

const EmptyIcon = styled(CameraIcon)`
${commonIconsStyles}
border-radius: ${(props) => props.theme.avatar.image.borderRadius};
`;
EmptyIcon.defaultProps = { theme: Base };

const EditContainer = styled.div`
box-sizing: ${(props) => props.theme.avatar.editContainer.boxSizing};
position: absolute;
width: ${(props) => props.theme.avatar.editContainer.width};
height: ${(props) => props.theme.avatar.editContainer.height};
top: ${(props) => props.theme.avatar.editContainer.top};
left: ${(props) => props.theme.avatar.editContainer.left};
transform: ${(props) => props.theme.avatar.editContainer.transform};
padding: ${(props) => props.theme.avatar.editContainer.padding};
text-align: ${(props) => props.theme.avatar.editContainer.textAlign};
line-height: ${(props) => props.theme.avatar.editContainer.lineHeight};
display: flex;
right: ${(props) => props.theme.avatar.editContainer.right};
bottom: ${(props) => props.theme.avatar.editContainer.bottom};
background-color: ${(props) =>
props.theme.avatar.editContainer.backgroundColor};
border-radius: ${(props) => props.theme.avatar.editContainer.borderRadius};
background: ${(props) =>
props.gradient
? props.theme.avatar.editContainer.linearGradient
: props.theme.avatar.editContainer.transparent};
height: ${(props) => props.theme.avatar.editContainer.height};
width: ${(props) => props.theme.avatar.editContainer.width};
align-items: center;
justify-content: center;
`;
EditContainer.defaultProps = { theme: Base };

Expand Down Expand Up @@ -129,7 +108,6 @@ const StyledAvatar = styled.div`
StyledAvatar.defaultProps = { theme: Base };

export {
EditLink,
EmptyIcon,
EditContainer,
AvatarWrapper,
Expand Down
26 changes: 5 additions & 21 deletions packages/asc-web-components/themes/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,28 +917,12 @@ const Base = {
},

editContainer: {
boxSizing: "border-box",
width: "100%",
height: "100%",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
padding: "75% 16px 5px",
textAlign: "center",
lineHeight: "19px",
right: "0px",
bottom: "0px",
backgroundColor: "#265a8f",
borderRadius: "50%",
linearGradient:
"linear-gradient(180deg, rgba(6, 22, 38, 0) 24.48%, rgba(6, 22, 38, 0.75) 100%)",
transparent: "transparent",
},

editLink: {
paddingLeft: "10px",
paddingRight: "10px",
borderBottom: "none",
display: "inline-block",
maxWidth: "100%",
textDecoration: "underline dashed",
height: "32px",
width: "32px",
},

image: {
Expand Down
25 changes: 5 additions & 20 deletions packages/asc-web-components/themes/dark.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,29 +880,14 @@ const Dark = {
},
},
editContainer: {
boxSizing: "border-box",
width: "100%",
height: "100%",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
padding: "75% 16px 5px",
textAlign: "center",
lineHeight: "19px",
right: "0px",
bottom: "0px",
backgroundColor: "#265a8f",
borderRadius: "50%",
linearGradient:
"linear-gradient(180deg, rgba(6, 22, 38, 0) 24.48%, rgba(6, 22, 38, 0.75) 100%)",
transparent: "transparent",
height: "32px",
width: "32px",
},

editLink: {
paddingLeft: "10px",
paddingRight: "10px",
borderBottom: "none",
display: "inline-block",
maxWidth: "100%",
textDecoration: "underline dashed",
},
image: {
width: "100%",
height: "100%",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class ContactField extends React.Component {
}

render() {
console.log("ContactField render");

const {
isDisabled,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class ContactsField extends React.Component {
}

render() {
console.log("ContactsField render");

const {
pattern,
contacts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class DateField extends React.Component {
}

render() {
console.log("DateField render");

const {
isRequired,
hasError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class DepartmentField extends React.Component {
};

render() {
console.log("DepartmentField render");

const {
isRequired,
isDisabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class EmailField extends React.Component {
}

render() {
console.log("EmailField render");

const {
isRequired,
hasError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class PasswordField extends React.Component {
}

render() {
console.log("PasswordField render");

const {
isRequired,
hasError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class RadioField extends React.Component {
}

render() {
//console.log("RadioField render");

const {
isRequired,
hasError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class TextChangeField extends React.Component {
}

render() {
console.log("TextChangeField render");

const {
isRequired,
hasError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class TextField extends React.Component {
}

render() {
console.log("TextField render");

const {
isRequired,
hasError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ class UpdateUserForm extends React.Component {
this.setState({ isLoading: true });
const { profile, setAvatarMax, personal } = this.props;

console.log("profile", profile);
if (isUpdate) {
createThumbnailsAvatar(profile.id, {
x: Math.round(result.x * avatar.defaultWidth - result.width / 2),
Expand Down Expand Up @@ -727,7 +726,6 @@ class UpdateUserForm extends React.Component {
source={this.props.avatarMax || profile.avatarMax}
userName={profile.displayName}
editing={true}
editLabel={t("Common:EditAvatar")}
editAction={
isMobile ? this.openAvatarEditorPage : this.openAvatarEditor
}
Expand Down
3 changes: 3 additions & 0 deletions public/images/pencil.react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.