Skip to content
Snippets Groups Projects
Commit a30d783b authored by Kyle Doherty's avatar Kyle Doherty
Browse files

user avatar component and activity styling

parent 3ad9e835
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ import React, { Component, PropTypes } from 'react'; ...@@ -4,6 +4,7 @@ import React, { Component, PropTypes } from 'react';
import OnClickOut from 'react-onclickout'; import OnClickOut from 'react-onclickout';
import cx from 'classnames'; import cx from 'classnames';
import UserAvatar from './UserAvatar.react';
import Icon from './Icon.react'; import Icon from './Icon.react';
export default class ProfileLink extends Component { export default class ProfileLink extends Component {
...@@ -22,20 +23,6 @@ export default class ProfileLink extends Component { ...@@ -22,20 +23,6 @@ export default class ProfileLink extends Component {
this.setState({ dropdownOpen: false }); this.setState({ dropdownOpen: false });
} }
displayInitials() {
let initials = '??';
const { user } = this.props;
if (user.first_name !== 'undefined') {
initials = user.first_name.substring(0, 1);
}
if (user.last_name !== 'undefined') {
initials = initials + user.last_name.substring(0, 1);
}
return initials;
}
render() { render() {
const { user, context } = this.props; const { user, context } = this.props;
...@@ -52,9 +39,7 @@ export default class ProfileLink extends Component { ...@@ -52,9 +39,7 @@ export default class ProfileLink extends Component {
<a className="NavDropdown-button NavItem flex align-center p2" onClick={this.toggleDropdown}> <a className="NavDropdown-button NavItem flex align-center p2" onClick={this.toggleDropdown}>
<div className="NavDropdown-button-layer"> <div className="NavDropdown-button-layer">
<div className="flex align-center"> <div className="flex align-center">
<span className="UserNick"> <UserAvatar user={user} text={'text-white'} />
<span className="UserInitials NavItem-text">{this.displayInitials()}</span>
</span>
<Icon name="chevrondown" className="Dropdown-chevron ml1" width="8px" height="8px" /> <Icon name="chevrondown" className="Dropdown-chevron ml1" width="8px" height="8px" />
</div> </div>
</div> </div>
......
...@@ -50,17 +50,6 @@ ...@@ -50,17 +50,6 @@
transition: background .2s linear; transition: background .2s linear;
} }
.UserNick {
border-width: 1px;
border-style: solid;
border-radius: 99px;
width: 2rem;
height: 2rem; /* set an explicit height since we want it to be square */
display: flex;
align-items: center;
justify-content: center;
}
.AdminNav .UserNick { .AdminNav .UserNick {
color: #fff; color: #fff;
border-color: #fff; border-color: #fff;
...@@ -72,13 +61,6 @@ ...@@ -72,13 +61,6 @@
color: #fff; color: #fff;
} }
.UserInitials,
.UserInitials:hover {
font-size: 0.85rem;
color: currentColor;
cursor: pointer;
}
.Actions { .Actions {
background-color: rgba(243,243,243,0.46); background-color: rgba(243,243,243,0.46);
border: 1px solid #E0E0E0; border: 1px solid #E0E0E0;
......
...@@ -141,13 +141,8 @@ export default class Activity extends Component { ...@@ -141,13 +141,8 @@ export default class Activity extends Component {
if (user) { if (user) {
const userColorIndex = userColors[user.id]; const userColorIndex = userColors[user.id];
const colorCssClass = this.colorClasses[userColorIndex]; const colorCssClass = this.colorClasses[userColorIndex];
const cssClasses = {
'UserNick': true,
'text-white': true
};
cssClasses[colorCssClass] = true;
return cx(cssClasses); return colorCssClass;
} else { } else {
return cx({ return cx({
'UserNick': true, 'UserNick': true,
......
'use strict'; 'use strict';
import React, { Component } from 'react'; import React, { Component } from 'react';
import Icon from 'metabase/components/Icon.react'; import Icon from 'metabase/components/Icon.react';
import IconBorder from '../../query_builder/IconBorder.react';
import UserAvatar from 'metabase/components/UserAvatar.react';
export default class ActivityItem extends Component { export default class ActivityItem extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.styles = {
initials: {
borderWidth: 0,
}
};
}
userInitials(user) {
let initials = '??';
if (user.first_name !== 'undefined') {
initials = user.first_name.substring(0, 1);
}
if (user.last_name !== 'undefined') {
initials = initials + user.last_name.substring(0, 1);
}
return initials;
} }
render() { render() {
const { item, description, userColors } = this.props; const { item, description, userColors } = this.props;
return ( return (
<div className="flex align-center"> <div className="ml1 flex align-center">
{ item.user ? <span>
<span styles={this.styles.initials} className={userColors}> { item.user ?
<span className="UserInitials">{this.userInitials(item.user)}</span> <UserAvatar user={item.user} background={userColors} style={{color: '#fff', borderWidth: '0'}}/>
</span> :
: <IconBorder style={{color: '#B8C0C8'}}>
<span styles={this.styles.initials} className={userColors}> <Icon name='sync' width={16} height={16} />
<span className="UserInitials"><Icon name='sync' width={16} height={16} /></span> </IconBorder>
</span> }
} </span>
<div className="ml2 full flex align-center"> <div className="ml2 full flex align-center" style={{fontSize: '1rem'}}>
<div className="text-grey-4"> <div className="text-grey-4">
<span className="text-dark">{description.userName}</span> <span className="text-dark">{description.userName}</span>
......
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
export default class ActivityStory extends Component { export default class ActivityStory extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.styles = { this.styles = {
modelLink: { borderWidth: '2px',
borderWidth: "2px" fontSize: '1.08rem',
}, borderColor: '#DFE8EA',
} }
} }
...@@ -23,8 +22,8 @@ export default class ActivityStory extends Component { ...@@ -23,8 +22,8 @@ export default class ActivityStory extends Component {
} }
return ( return (
<div className="ml2 mt1 border-left flex" style={{borderWidth: '3px'}}> <div className="mt1 border-left flex" style={{borderWidth: '3px', marginLeft: '22px', borderColor: '#F2F5F6'}}>
<div style={this.styles.modelLink} className="flex full ml4 bordered rounded p2"> <div className="flex full ml4 bordered rounded p2" style={this.styles}>
{ story.bodyLink ? { story.bodyLink ?
<a className="link" href={story.bodyLink}>{story.body}</a> <a className="link" href={story.bodyLink}>{story.body}</a>
: :
......
'use strict'; 'use strict';
import React, { Component } from 'react';
import cx from "classnames"; import cx from "classnames";
var IconBorder = React.createClass({ export default class IconBorder extends Component {
displayName: 'IconBorder', constructor() {
getDefaultProps: function () { super();
return { this.state = {}
borderWidth: '1px', }
borderStyle: 'solid', componentDidMount() {
borderColor: 'currentcolor', this.setState({
rounded: true childWidth: React.findDOMNode(this.refs.child).offsetWidth
} })
}, }
computeSize: function () { computeSize () {
var width = parseInt(this.props.children.props.width, 10); let width = parseInt(this.state.childWidth, 10);
return width * 2; return width * 2;
}, }
render: function () {
var classes = cx({ render() {
const classes = cx({
'flex': true, 'flex': true,
'layout-centered': true 'layout-centered': true
}); });
var styles = { const styles = {
width: this.computeSize(), width: this.computeSize(),
height: this.computeSize(), height: this.computeSize(),
borderWidth: this.props.borderWidth, borderWidth: this.props.borderWidth,
borderStyle: this.props.borderStyle, borderStyle: this.props.borderStyle,
borderColor: this.props.borderColor borderColor: this.props.borderColor,
lineHeight: '1px', /* HACK this is dumb but it centers the icon in the border */
} }
if (this.props.borderRadius) { if (this.props.borderRadius) {
...@@ -37,11 +40,17 @@ var IconBorder = React.createClass({ ...@@ -37,11 +40,17 @@ var IconBorder = React.createClass({
} }
return ( return (
<span className={classes + ' ' + this.props.className} style={styles}> <span className={classes + ' ' + this.props.className} style={Object.assign(styles, this.props.style)}>
{this.props.children} <span ref="child">{this.props.children}</span>
</span> </span>
); );
} }
}); }
export default IconBorder; IconBorder.defaultProps = {
borderWidth: '1px',
borderStyle: 'solid',
borderColor: 'currentcolor',
rounded: true,
style: {},
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment