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

Ticket #598 updated #639

Merged
merged 23 commits into from
Jun 4, 2024
Merged

Conversation

zarSou9
Copy link
Contributor

@zarSou9 zarSou9 commented May 25, 2024

Unlike the previous pr for this ticket, this one uses the Action component. I've created a ButtonSecondary component as a smaller alternative to the Button component with slightly different styling as to match the Figma.

tailwindcss was added to improve the styling experience

Note: All 3 imports in the root.css file are needed for tailwind to work correctly. Also turns out the reference problems were happening cus I was using pnpm.

@zarSou9 zarSou9 requested a review from mruwnik May 25, 2024 21:17
hint?: string
children?: ReactNode | ReactNode[]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the children. This allows extra components to be provided

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You right, I added it back

hint?: string
children?: ReactNode | ReactNode[]
dissabled?: boolean
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1,15 @@
.button-secondary .tool-tip {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the whole point of tailwind to avoid having extra css?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tailwind does have some limitations. i.e. it is difficult to use selectors to control the styling of child elements.

return () => clearInterval(timeout)
}, [showFeedback])
if (showThanks && thanksRef.current) {
thanksRef.current.style.opacity = '1'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use classes for css. Or contitional rendering if you want to use js. Don't mix the two - there lies madness

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this way, rather than the previous approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You right on both accounts. I've updated the code

<Action
pageid={pageid}
showText={!!labels}
actionType={ActionType.HELPFUL}
active={vote === 'helpful'}
dissabled={!!vote}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

const [showFeedbackForm, setShowFeedbackForm] = useState(false)
const [vote, setVote]: any = useState(undefined)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this means that each time the page gets refreshed, the user can vote for the article again. The previous solution would rememeber whether an article was liked or not between refreshes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good point. I've updated the code, but note that I had to pass a setVoted function to the child Action components so that the feedback knew to set the other Action disabled. Its the best I could do. Also the handler function for voting in the questions.actions file is throwing an error, and thus the feedback button is returning to its null state after you press it.

@zarSou9
Copy link
Contributor Author

zarSou9 commented May 26, 2024

I've incorporated all of your feedback except the check is failing for absolutely now reason. A prettier error even though I have run prettier. Oh well, I'm going to sleep

@zarSou9
Copy link
Contributor Author

zarSou9 commented May 29, 2024

Ok, no more tailwind, should be ready to merge 🤞

article .footer-comtainer {
display: flex;
align-items: center;
margin-top: var(--spacing-56);
margin-bottom: var(--spacing-24);
gap: 16px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to avoid raw pixel values. In root.css there's a bunch of available variables that should be used for sizing and coiours. You use them as var(<var name), like in the previous lines. So in this case it'd be gap: var(--spacing-16);. This is important both for consistency (as it's easier to change everything at once), but also because the mobile version often has subtle differences in spacing which should be reflected by this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

app/components/ButtonSecondary/index.tsx Outdated Show resolved Hide resolved
}

/* Comment to Nemo when he reviews: why didn't you just do this the way you did the settings buttons? */
.select-option {
height: var(--spacing-48);
padding: var(--spacing-8) var(--spacing-16);
border-radius: 6px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a var here. Or consider adding the rounded class to whatever is using this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I've changed it. The only reason I used the 6px is because that's what the figma said, but the var for --border-radius is 4px. I totally get the value of only needing to change one variable though so yeah.

app/components/Feedback/feedback.css Show resolved Hide resolved

.submit {
height: var(--spacing-48);
border-radius: 6px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's actually a variable for border radius so use that var!

@@ -28,7 +54,6 @@
padding: var(--spacing-12);
margin: var(--spacing-40) 0;
box-sizing: content-box;
background: pink;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. interesting...


{showFeedback && <div className="thanks">Thanks for your feedback!</div>}
<p className={'thanks ' + (showThanks ? 'show' : 'hide')}>Thank you for your feedback!</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, why are you doing it this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I wanted a css fade in/out transition which can't be done easily with conditional rendering to my knowledge. (in svelte you can tho 🙂)


{showFeedbackForm && (
<FeedbackForm
onSubmit={onSubmit}
onSubmit={(att) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you name this something more intuitive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too true

@@ -160,6 +160,9 @@ h2 {
letter-spacing: -0.14px;
}

.leading-0 {
line-height: 0 !important;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was trying to style the button, It kept putting this annoying space below it. After some testing, I discovered it was a line-height issue. I've added this to the root incase there are other circumstances where there is a line-height problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except sometimes the button actually goes to two lines. In which case this would end up looking really weird and bad obviously.

@@ -173,13 +184,9 @@ export const Action = ({
<input type="hidden" name="incBy" value={actionTaken ? -1 : 1} />
<input type="hidden" name="stateString" value={stateString} />
{children}
<Button className={className}>
<ButtonSecondary disabled={disabled} active={actionTaken} tooltip={hint}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also just a normal button with a custom tooltip

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

Copy link
Collaborator

@mruwnik mruwnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@melissasamworth can you check the css bits? The code seems fine

}

.active {
background-color: #edfaf9;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should also be vars and use the colours in root.css

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you right

@@ -20,6 +20,15 @@
letter-spacing: -0.16px;
}

.button-secondary {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this differ from the .secondary class below? That is conceptually what's the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second version of the button, as represented in the figma, is significantly stylistically different, mainly as a result of the difference in hover states (the main button shows and outline, and the second shows a background). This also effects how sibling buttons are grouped. The .secondary class is a slight difference to the main button version, and the .button-secondary class is a second version of the button.

app/components/Feedback/Form.tsx Outdated Show resolved Hide resolved
app/components/Article/index.tsx Outdated Show resolved Hide resolved
app/components/ButtonSecondary/index.tsx Outdated Show resolved Hide resolved
@@ -160,6 +160,9 @@ h2 {
letter-spacing: -0.14px;
}

.leading-0 {
line-height: 0 !important;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me

@@ -160,6 +160,9 @@ h2 {
letter-spacing: -0.14px;
}

.leading-0 {
line-height: 0 !important;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except sometimes the button actually goes to two lines. In which case this would end up looking really weird and bad obviously.


.submit {
height: var(--spacing-48);
border-radius: 6px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's actually a variable for border radius so use that var!

app/components/Feedback/feedback.css Show resolved Hide resolved
app/components/Feedback/feedback.css Show resolved Hide resolved
Copy link
Contributor Author

@zarSou9 zarSou9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing review

@zarSou9 zarSou9 dismissed melissasamworth’s stale review June 4, 2024 21:09

fixing review error

@melissasamworth melissasamworth merged commit dc6a47c into StampyAI:stampy-redesign Jun 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants