Skip to content

Commit

Permalink
more sane typing for the imageSize prop
Browse files Browse the repository at this point in the history
  • Loading branch information
alicewriteswrongs committed Jul 6, 2018
1 parent 3cf5cad commit f048197
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions static/js/components/CommentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ReplyToCommentForm, EditCommentForm } from "./CommentForms"
import CommentVoteForm from "./CommentVoteForm"
import CommentRemovalForm from "./CommentRemovalForm"
import { renderTextContent } from "./Markdown"
import ProfileImage, { PROFILE_IMAGE_SMALL } from "../containers/ProfileImage"

import { preventDefaultAndInvoke, userIsAnonymous } from "../lib/util"
import {
Expand All @@ -28,7 +29,6 @@ import type {
import type { FormsState } from "../flow/formTypes"
import type { CommentRemoveFunc } from "./CommentRemovalForm"
import type { CommentVoteFunc } from "./CommentVoteForm"
import ProfileImage from "../containers/ProfileImage"

type LoadMoreCommentsFunc = (comment: MoreCommentsInTree) => Promise<*>
type BeginEditingFunc = (fk: string, iv: Object, e: ?Object) => void
Expand Down Expand Up @@ -116,7 +116,7 @@ export default class CommentTree extends React.Component<*, *> {
image_small: comment.profile_image,
username: SETTINGS.username
})}
imageSize="small"
imageSize={PROFILE_IMAGE_SMALL}
/>
<div className="comment-contents">
<div className="author-info">
Expand Down
4 changes: 2 additions & 2 deletions static/js/components/ExpandedPostDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import R from "ramda"
import { EditPostForm } from "./CommentForms"
import { renderTextContent } from "./Markdown"
import Embedly from "./Embedly"
import ProfileImage from "../containers/ProfileImage"
import ProfileImage, { PROFILE_IMAGE_MICRO } from "../containers/ProfileImage"
import DropdownMenu from "./DropdownMenu"
import SharePopup from "./SharePopup"

Expand Down Expand Up @@ -210,7 +210,7 @@ export default class ExpandedPostDisplay extends React.Component<
name: post.author_name,
image_small: post.profile_image
})}
imageSize="micro"
imageSize={PROFILE_IMAGE_MICRO}
/>
<div className="author-name">{post.author_name}</div>
</div>
Expand Down
10 changes: 6 additions & 4 deletions static/js/components/ProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
/* global SETTINGS: false */
import React from "react"

import ProfileImage from "../containers/ProfileImage"
import ProfileImage, { PROFILE_IMAGE_MEDIUM } from "../containers/ProfileImage"

import { validationMessage } from "../lib/validation"
import { goBackAndHandleEvent } from "../lib/util"

import type {
Profile,
ProfilePayload,
ProfileValidation
} from "../flow/discussionTypes"
import { validationMessage } from "../lib/validation"
import { goBackAndHandleEvent } from "../lib/util"

type ProfileFormProps = {
form: ProfilePayload,
Expand Down Expand Up @@ -45,7 +47,7 @@ export default class ProfileForm extends React.Component<*, void> {
profile={profile}
userName={profile.username}
editable={profile.username === SETTINGS.username}
imageSize="medium"
imageSize={PROFILE_IMAGE_MEDIUM}
/>
<form onSubmit={onSubmit} className="form">
<div className="row image-and-name">
Expand Down
1 change: 1 addition & 0 deletions static/js/components/ProfileImageUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Dropzone from "react-dropzone"

import CropperWrapper from "./CropperWrapper"
import { FETCH_PROCESSING } from "../actions/image_upload"

import type { ImageUploadState } from "../reducers/image_upload"

const onDrop = R.curry((startPhotoEdit, files) => startPhotoEdit(...files))
Expand Down
4 changes: 2 additions & 2 deletions static/js/components/UserMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react"
import { Link } from "react-router-dom"

import DropdownMenu from "./DropdownMenu"
import ProfileImage from "../containers/ProfileImage"
import ProfileImage, { PROFILE_IMAGE_SMALL } from "../containers/ProfileImage"

import { isProfileComplete } from "../lib/util"
import { profileURL, SETTINGS_URL } from "../lib/url"
Expand All @@ -28,7 +28,7 @@ export default class UserMenu extends React.Component<*, *> {
userName={SETTINGS.username}
profile={profile}
onClick={toggleShowUserMenu}
imageSize="small"
imageSize={PROFILE_IMAGE_SMALL}
/>
{SETTINGS.profile_ui_enabled && !isProfileComplete(profile) ? (
<div className="profile-incomplete" />
Expand Down
9 changes: 8 additions & 1 deletion static/js/containers/ProfileImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ import type { Dispatch } from "redux"

const formatPhotoName = photo => `${photo.name.replace(/\.\w*$/, "")}.jpg`

type ImageSize = "micro" | "small" | "medium"
export const PROFILE_IMAGE_MICRO: "micro" = "micro"
export const PROFILE_IMAGE_SMALL: "small" = "small"
export const PROFILE_IMAGE_MEDIUM: "medium" = "medium"

type ImageSize =
| typeof PROFILE_IMAGE_MICRO
| typeof PROFILE_IMAGE_SMALL
| typeof PROFILE_IMAGE_MEDIUM

type ProfileImageProps = {
clearPhotoEdit: () => void,
Expand Down
4 changes: 2 additions & 2 deletions static/js/containers/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import R from "ramda"
import DocumentTitle from "react-document-title"

import Card from "../components/Card"
import ProfileImage from "./ProfileImage"
import ProfileImage, { PROFILE_IMAGE_MEDIUM } from "./ProfileImage"
import withLoading from "../components/Loading"
import withSingleColumn from "../hoc/withSingleColumn"

Expand Down Expand Up @@ -74,7 +74,7 @@ class ProfilePage extends React.Component<*, void> {
profile={profile}
userName={userName}
editable={editable}
imageSize="medium"
imageSize={PROFILE_IMAGE_MEDIUM}
/>
<div className="row image-and-name">
<div className="profile-view-fullname">
Expand Down

0 comments on commit f048197

Please sign in to comment.