-
Notifications
You must be signed in to change notification settings - Fork 0
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
Catalog cards #63
base: main
Are you sure you want to change the base?
Catalog cards #63
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments in the code.
General questions:
- Should we be adding loading states for async data?
- With
MAX_LENGTH
, does this need to be flexible? i.e. should we be passing it in as an optional property while keeping the default? - Will the cards require click handlers in the future?
src/components/core/CatalogCard.tsx
Outdated
export type IndicatorTag = "API" | "Catalog"; | ||
|
||
export interface BaseCatalog { | ||
// eslint-disable-next-line react/no-unused-prop-types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you think of a way to use id in here?
If not, would it make sense to make it optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in the Catalog component when rendering each Catalog card (set key), so we still expect the data to have id
property. It's showing a warning because the file we're in doesn't use id
. For the interfaces that are used in multiple places, should we move it to somewhere else?
I would love to do something like this since CatalogList (rename later) and CatalogCard are so closely related, but not sitting well with our structure.
- components
- Catalog (directory)
- CatalogList.tsx
- CatalogCard.tsx
- ... others tsx
- 1 file for typescript types if needed
- css module
- test
- index.ts to export reusable components
- Catalog (directory)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that structure makes sense here and allows the interface to be in a different file too. The current flat directory structure is no very scaleable so moving to something more like this makes more sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done this change in my local. Should I push it now or should we discuss more about it, as it's gonna change the way we structure drastically? If doing this, we won't differentiate core / composite components anymore in the codebase, but still have component types on storybook.
src/components/core/CatalogCard.tsx
Outdated
import type { DateValue } from "react-aria"; | ||
import styles from "./CatalogCard.module.css"; | ||
|
||
export type TemporalExtent = [DateValue, DateValue?]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we be more specific about DateValue null/undefined cases?
Maybe not, but I'm interested to know what happens if the 1st DateValue in the array is nullish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we expect the library user to pass in one or two DateValue for TemporalExtent
So if user passes in null
for the first item or anything that doesn't satisfy the type, the editor is gonna show an error. I think type checking with typescript is good enough. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I am happy with this approach in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been putting some more thought into this as I modify the DatePicker component.
I'm not convinced that passing in props which use react-aria types like DateValue
is ideal. It introduces another dependency and requires the developer to understand the types in the library.
There are a few alternatives, but I'm leaning to passing in regular JS Date
objects and converting them to a react-aria type like DateValue
within the component. What do you think?
As an example, here's what I'm working on for the DatePicker: #66
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me
src/components/core/CatalogCard.tsx
Outdated
shouldTruncateDescription | ||
? `${initialDescription.slice(0, MAX_LENGTH)}${isLongText ? "..." : ""}` | ||
: initialDescription, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this to a utility function. Something like this:
const truncateDescription = (text: string, maxLength: number) => {
if (text.length <= maxLength) return text;
return `${text.slice(0, maxLength)}...`;
};
There's actually a utils
directory. The aim is to abstract useful utilities so we can use them without components in the future if required.
src/components/core/CatalogCard.tsx
Outdated
onPress={() => | ||
setShouldTruncateDescription(!shouldTruncateDescription) | ||
} | ||
aria-expanded={!shouldTruncateDescription} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add an aria-label
property here for accessibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re Catalog count:
- I think we'll need something in place if the catalog count is in the hundreds+ Like if there's 3 digits in there.
- Also 8px is too small. I would bump it up to at least 12px. @e-e-james thoughts on font size?
Re: General questions @JBurkinshaw
|
@alanjleonard I'm working on this. We can remove fixed width and height, add some padding and aspect-ratio 1/1 so that the circle will grow as we have more digits. 4 digits or less look fine.
|
@max172-hqt |
border-radius: 50%; | ||
display: inline-flex; | ||
justify-content: center; | ||
align-items: center; | ||
color: #fff; | ||
font-size: 10px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@max172-hqt Another thought on this. Can you use CSS variables from src/components/styles/theme.css
to set as many of these as possible please? Thinking in terms of color, font size, border radius and whatever else you can apply. In the work I'm doing on the datepicker I have added a new variable Edit: Forget this. Let's stay with the existing --border-radius: 4px;
but we'll need some input from the design team to align on the approach we take hereborder-radius-*
CSS vars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this, I feel like we’re trying to figure out some default values / spacing in the theme.css file, which are very similar to defaults from TailwindCSS or similar libraries. A few things that made it work really well that I think we can adopt are:
- consistent spacing. Everything is proportional to 1rem, which is the default browser / html font size (16px). So when user changes default font size, everything will scale correctly. Right now we override default font size to 14px, so it doesn’t make sense to use rem. Reference
- have a normalize css rules. This is to solve browser inconsistencies and make working with semantic HTML tags easier (eg. remove margins from h1,h2…p tags). Looks like we’re mostly using div tags at the moment.
- other than that, a lot of default colors, utility classes, easy to work with dark themes and responsive UIs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context, currently we're using the Vanilla CSS "starter kit" found here. It comes with css files for the base react-aria components, along with a theme.css
file which we based our theme.css
file in spk-components on.
- I am fine with using consistent spacing proportional to 1rem if we're all onboard.
- Normalize css is something I've thought about and I think it's a good idea. I think adding it should be tackled as a separate issue though.
- I think the default colours are deliberately minimal in our
theme.css
. It should handle dark/light themes too but we haven't focussed on that yet
I think to keep inline with how we're going to render the description in the different detail sections, we can
Probably makes sense to do this in a different ticket, or after that card is complete. I'll make another placeholder ticket for it. |
Description
Please include a summary of the changes and relevant context. List any dependencies that are required for this change.
Related issue: #62
Type of change
Delete options that are not relevant.
Instructions
Describe the steps required to verify that the changes are functioning as expected.
How Has This Been Tested?
Describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
Checklist: