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

Stampy redesign article action buttons #394

Merged
merged 6 commits into from
Feb 14, 2024
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
17 changes: 5 additions & 12 deletions app/components/Article/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import {useState} from 'react'
import KeepGoing from '~/components/Article/KeepGoing'
import CopyIcon from '~/components/icons-generated/Copy'
import EditIcon from '~/components/icons-generated/Pencil'
import ThumbUpIcon from '~/components/icons-generated/ThumbUp'
import ThumbDownIcon from '~/components/icons-generated/ThumbDown'
import Button, {CompositeButton} from '~/components/Button'
import type {Question, Glossary} from '~/server-utils/stampy'
import {Action, ActionType} from '~/routes/questions.actions'
import type {Glossary, Question} from '~/server-utils/stampy'
import Contents from './Contents'
import './article.css'

Expand Down Expand Up @@ -34,15 +33,9 @@ const ArticleFooter = (question: Question) => {
</div>
<span>Did this page help you?</span>

<CompositeButton>
<Button className="secondary" action={() => alert('Like')}>
<ThumbUpIcon />
<span className="teal-500">Yes</span>
</Button>
<Button className="secondary" action={() => alert('Dislike')}>
<ThumbDownIcon />
<span className="teal-500">No</span>
</Button>
<CompositeButton className="flex-container">
<Action pageid={question.pageid} showText={true} actionType={ActionType.HELPFUL} />
<Action pageid={question.pageid} showText={true} actionType={ActionType.UNHELPFUL} />
</CompositeButton>
</div>
)
Expand Down
5 changes: 5 additions & 0 deletions app/components/Button/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
box-shadow: 0px 16px 40px rgba(175, 183, 194, 0.2);
}

.composite-button > form .button,
.composite-button > .button {
border-radius: 0;
border-radius: 0;
Expand All @@ -63,13 +64,15 @@
box-shadow: revert;
}

.composite-button > form:first-child .button,
.composite-button > .button:first-child {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
border-left-width: 1px;
border-right: 1px solid transparent;
}

.composite-button > form:last-child .button,
.composite-button > .button:last-child {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
Expand All @@ -78,10 +81,12 @@
}

/* Make sure the first button doesn't have a negative margin */
.composite-button > form:first-child .button,
.composite-button > .button:first-child {
margin-left: 0;
}

.composite-button form .button:hover,
.composite-button .button:hover {
border-width: 1px;
}
Expand Down
8 changes: 6 additions & 2 deletions app/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ const Button = ({children, action, tooltip, icon, className}: ButtonProps) => {
)
}

export const CompositeButton = ({children}: {children: ReactNode}) => (
<div className="composite-button">{children}</div>
export interface CompositeButtonProps {
children: ReactNode
className?: string
}
export const CompositeButton = ({children, className}: CompositeButtonProps) => (
<div className={`composite-button ${className || ''}`}>{children}</div>
)

export default Button
7 changes: 7 additions & 0 deletions app/newRoot.css
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,10 @@ a:not(:hover, :focus-visible) {
justify-content: flex-start;
gap: 10.9vw;
}

.icon-link path {
stroke: var(--colors-cool-grey-600);
}
.icon-link.focused path {
stroke: var(--colors-teal-600);
}
30 changes: 12 additions & 18 deletions app/routes/questions.actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ import type {ActionFunctionArgs} from '@remix-run/cloudflare'
import {Form, useSearchParams} from '@remix-run/react'
import {redirect, json} from '@remix-run/cloudflare'
import {makeColumnIncrementer} from '~/server-utils/stampy'
import {
DarkLight,
Edit,
Flag,
Followup,
Hide,
Like,
Search,
Dislike,
} from '~/components/icons-generated'
import ThumbUpIcon from '~/components/icons-generated/ThumbUp'
import ThumbDownIcon from '~/components/icons-generated/ThumbDown'
import Button from '~/components/Button'
import {DarkLight, Edit, Flag, Followup, Hide, Like, Search} from '~/components/icons-generated'

export enum ActionType {
DARKLIGHT = 'darkLight',
Expand Down Expand Up @@ -56,13 +50,13 @@ const actions = {
handler: makeColumnIncrementer('Request Count'),
},
helpful: {
Icon: Like,
title: 'Helpful',
Icon: ThumbUpIcon,
title: 'Yes',
handler: makeColumnIncrementer('Helpful'),
},
unhelpful: {
Icon: Dislike,
title: 'Unhelpful',
Icon: ThumbDownIcon,
title: 'No',
handler: makeColumnIncrementer('Unhelpful'),
},
hide: {
Expand Down Expand Up @@ -147,7 +141,7 @@ export const Action = ({pageid, actionType, showText = true, children, ...props}
if (response.ok !== true) setActionTaken(!actionTaken)
}

const className = 'icon-link' + (actionTaken ? ' focused' : '')
const className = 'secondary icon-link' + (actionTaken ? ' focused' : '')

return (
<Form
Expand All @@ -163,10 +157,10 @@ export const Action = ({pageid, actionType, showText = true, children, ...props}
<input type="hidden" name="incBy" value={actionTaken ? -1 : 1} />
<input type="hidden" name="stateString" value={stateString} />
{children}
<button className={className} title={title} type="button">
<Button className={className}>
<Icon />
{showText && title}
</button>
<span className={actionTaken ? 'teal-500' : 'grey'}> {showText && title}</span>
</Button>
</Form>
)
}
Loading