Skip to content

Conversation

@HS-90
Copy link
Collaborator

@HS-90 HS-90 commented Jun 16, 2022

Title: enhancement : Create a lessons homepage with Lesson Card components for Dojo(Admin).

Description:

Related to #1959

Create a lessons homepage with the ability to Add New Lessons, Edit Lessons, view questions from students for each lesson.
Note: In the initial PR, only the new admin Lesson Card will be submitted. Upon approval of the Lesson Card, the Lessons home page will be created and submitted in the following PR.

AdminLessonCard Component screenshot:
Screenshot from 2022-06-15 21-40-54

@vercel
Copy link

vercel bot commented Jun 16, 2022

@HS-90 is attempting to deploy a commit to the c0d3-prod Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Jun 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
c0d3-app ✅ Ready (Inspect) Visit Preview Jun 20, 2022 at 1:25AM (UTC)

@codecov
Copy link

codecov bot commented Jun 16, 2022

Codecov Report

Merging #1989 (e291571) into master (9f9cdcc) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1989   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          168       169    +1     
  Lines         2881      2886    +5     
  Branches       760       761    +1     
=========================================
+ Hits          2881      2886    +5     
Impacted Files Coverage Δ
components/admin/lessons/AdminLessonCard.tsx 100.00% <100.00%> (ø)

export const Basic = () => {
return (
<AdminLessonCard
heading={props.heading}
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 try doing {...props}

description: string
pendingFlaggedQuestions: number
editLessonUrl: string
width?: string
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are width and height strings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought in React when you set it to a px or % it needed to be in a string format

return (
<div
className={styles.container}
style={{ width: `${width}`, height: `${height}` }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a need for AdminLessonCard to take in width and height props?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was taking into consideration when designing the overall page i may need to customize the size of the component

<Link href={editLessonUrl}>
<button
className="btn btn-secondary"
style={{ color: '#5440D8', fontWeight: 700 }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you set css through inline styling here, and then everywhere else you set it through className(except for the dynamically set width and height on line 25)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

my thought process was that it was only a couple of lines to get the button to appear how i wanted vs alot more for the other elements, but i can revise this to make it consistent with the rest.

Copy link
Contributor

Choose a reason for hiding this comment

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

Consistency makes life easier for future engineers debugging your code, I vote for that.

pendingFlaggedQuestions,
editLessonUrl,
width,
height
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you know that component prop design is part of the front end system design? https://youtu.be/9aOXGE7wAZo?t=645

I would have designed this differently because:

  1. This is specific to a lesson (per the component name description). Therefore, I think the heading / description / url should be handled within the component. This way, your component simply takes a lesson Prop.
  2. This is specific to the admin page. Therefore, adding customization is a bit of overkill. Customization ability should only be added in when a component is made to be super generic. I would take out width/height.

So for propes I would have:

lesson, pendingFlaggedQuestions and that's it

Copy link
Collaborator Author

@HS-90 HS-90 Jun 16, 2022

Choose a reason for hiding this comment

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

That's good to know.

I was taking into consideration when designing the overall page i may need to customize the size of the component amongst other things.

Is there a way for me to view an example of the deconstructed items of a lesson object?

Copy link
Contributor

Choose a reason for hiding this comment

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

i may need to customize the size of the component amongst other things.

I would add the width/height when I actually have a use case /need for custom sizing. Otherwise I may be over engineering the component.

Here's a page using Lesson data type: https://github.com/garageScript/c0d3-app/blob/master/pages/curriculum.tsx#L19

Lesson Type Defined here: https://github.com/garageScript/c0d3-app/blob/master/graphql/index.tsx#L86

lesson: {
title: 'Foundations of Javascript',
description: 'A super simple introduction to help you get started!',
docUrl: undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

i dont think this field needs to be passed if it is passed as undefined. Since the type definition says it is an optional field

HS-90 added 2 commits June 17, 2022 22:04
added expect.assertions(1) to test
should've been expect.assertions(2)
flex-direction: column;
justify-content: center;
align-items: center;
padding: 2% 3% 2% 3%;
Copy link
Member

Choose a reason for hiding this comment

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

Why percent rather than px? It's unusual to set the padding or margin as a percentage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was using % thinking the padding would dynamically adjust on the page depending on how large the overall component will be. I initially thought using a fixed px might make it not as scalable when taking into account the eventual adjustment in size to fit into the lessons home page. I can change to px if this is best practice.

Copy link
Contributor

Choose a reason for hiding this comment

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

px for padding is best practice, you want the padding to always be the same. Usually the only thing that changes with screen size is:

  1. the text should scale with screen size
  2. Overall layout of the page should change with screen size

justify-content: center;
align-items: center;
padding: 2% 3% 2% 3%;
background: #ffffff;
Copy link
Member

Choose a reason for hiding this comment

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

NIT: To stay consistent, I would import colors.$bg-light from colors.module.scss.


.container__heading {
font-family: Rubik;
font-style: normal;
Copy link
Member

Choose a reason for hiding this comment

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

This property can be removed, as it's normal by default.

text-align: center;
flex: none;
order: 0;
flex-grow: 0;
Copy link
Member

@flacial flacial Jun 18, 2022

Choose a reason for hiding this comment

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

flex, order, and flex-grow can be removed. Figma adds unnecessary CSS properties to the auto-generated CSS.

}

.container__button {
color: #5440d8;
Copy link
Member

Choose a reason for hiding this comment

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

Use HSL rather than HEX, as it's human-readable.

flex-direction: column;
justify-content: center;
align-items: center;
padding: 30px 53px 30px 53px;
Copy link
Member

Choose a reason for hiding this comment

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

A shorthand would be padding: 30px 53px

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be updated

font-family: Inter;
font-size: 14px;
margin-bottom: 3%;
margin-top: 2%;
Copy link
Member

Choose a reason for hiding this comment

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

These should also be px

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated as well

Copy link
Contributor

@songz songz left a comment

Choose a reason for hiding this comment

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

flacial's comments

<div className={styles.container__heading}>{title}</div>

<div className={styles.container__description}>
{description} The Dojo is a space for you to store your coding journal
Copy link
Contributor

Choose a reason for hiding this comment

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

The Dojo is a space for you to store your coding journal and keep track of your learnings <- take this out please, I think we only want to display the description

@songz
Copy link
Contributor

songz commented Jun 20, 2022

rebuild

@HS-90 HS-90 merged commit 6208625 into garageScript:master Jun 20, 2022
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.

4 participants