-
Notifications
You must be signed in to change notification settings - Fork 4
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
Crash details: make change log collapsible #1655
base: nextjs
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for vision-zero-nextjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
app/components/ChangeLog.tsx
Outdated
defaultActiveKey={expandedItem} | ||
// on accordion click save new expanded item state to local storage | ||
onSelect={(e) => { | ||
const localStorageValue = e !== null ? "0" : JSON.stringify(null); // local storage value must be a string type |
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 was getting a typescript linting error when just setting to null "Type 'null' is not assignable to type 'string'." and this is just never something i would have been super aware before programming in a strongly typed language. its weird but interesting having to take into account the parameter typing of external methods that we dont control, like setItem
,
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'm glad you shared about this in dev sync because it is a TIL for me too! Purely in opinion zone here but I think it would be okay to use the String constructor to make null into a string to work around this too. 🤷
I do think the e
could be change to eventKey
after I found myself wondering how these Bootstrap accordions work. The docs show that the first parameter in the callback is a string and the second is an event object which I expected this e
to be when I read the code.
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 it would be okay to use the String constructor to make null into a string to work around this to
i like this suggestion a lot. my inclination would be to restrict expandedItem
to being a string only, and deal with conversion to a string with the String
constructor. And that way we can always store whatever String(e)
is into local storage without caring about it's value beyond that.
also, for what it's worth we don't have to use "0"
as the key value. we could use something that's more obviously a string, like "recordHistory"
. and it might to be good to stash that value as const
var 🤷
One other detail @roseeichelmann—I think that instead of the defaultActiveKey
prop, the activeKey
prop is a better choice to use instead. i see this kind of like using the value
prop instead of defaultValue
prop on a controlled form input.
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.
these are all great comments, thanks yall! just pushed these changes
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.
Looks great and I'm happy to see this feature carrying over into the new app. I left one suggestion for the code, but this works just as expected! 💯
app/components/ChangeLog.tsx
Outdated
defaultActiveKey={expandedItem} | ||
// on accordion click save new expanded item state to local storage | ||
onSelect={(e) => { | ||
const localStorageValue = e !== null ? "0" : JSON.stringify(null); // local storage value must be a string type |
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'm glad you shared about this in dev sync because it is a TIL for me too! Purely in opinion zone here but I think it would be okay to use the String constructor to make null into a string to work around this too. 🤷
I do think the e
could be change to eventKey
after I found myself wondering how these Bootstrap accordions work. The docs show that the first parameter in the callback is a string and the second is an event object which I expected this e
to be when I read the code.
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.
Rose—this is looking really good. I requested to changes to tighten up some typing and naming.
I also want to remark that I'd like to nix the blue background on the accordion header when it's expanded. but i am happy to stash that in a follow-up issue. as part of that follow-up work it would be nice toto make the header look the same as the bootstrap Card
header for consistency with the other cards on the page, i think?
app/components/ChangeLog.tsx
Outdated
import Table from "react-bootstrap/Table"; | ||
import Accordion from "react-bootstrap/Accordion"; | ||
import { formatDateTime } from "@/utils/formatters"; | ||
import ChangeLogDetails from "./ChangeLogDetails"; |
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 convert to an absolute import 😇
app/components/ChangeLog.tsx
Outdated
defaultActiveKey={expandedItem} | ||
// on accordion click save new expanded item state to local storage | ||
onSelect={(e) => { | ||
const localStorageValue = e !== null ? "0" : JSON.stringify(null); // local storage value must be a string type |
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 it would be okay to use the String constructor to make null into a string to work around this to
i like this suggestion a lot. my inclination would be to restrict expandedItem
to being a string only, and deal with conversion to a string with the String
constructor. And that way we can always store whatever String(e)
is into local storage without caring about it's value beyond that.
also, for what it's worth we don't have to use "0"
as the key value. we could use something that's more obviously a string, like "recordHistory"
. and it might to be good to stash that value as const
var 🤷
One other detail @roseeichelmann—I think that instead of the defaultActiveKey
prop, the activeKey
prop is a better choice to use instead. i see this kind of like using the value
prop instead of defaultValue
prop on a controlled form input.
app/components/ChangeLog.tsx
Outdated
@@ -9,6 +9,9 @@ import { | |||
ChangeLogEntryEnriched, | |||
} from "@/types/changeLog"; | |||
|
|||
// used to track the accordion expanded state of the change log | |||
const localStorageKey = "expandedItem"; |
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.
would you mind making this a little more descriptive and specific instead of "expandedItem"
, like "crashHistoryCardExpandedItem"
?
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.
btw, i created cityofaustin/atd-data-tech#20575 to add in support for version local storage across the app 👍
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 looks super Rose. Really well done. I think the comments from other reviewers all make sense and get support from me, and I added one little thing concerning a color choice, but that's hardly enough to stop this from shipping. Send it out to sea!
🚢🚢🚢🚢🚢
}} | ||
> | ||
<Accordion.Item eventKey="0"> | ||
<Accordion.Header>Record history</Accordion.Header> |
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 header gets a baby blue color when it's expanded, and it's the only header row in on the page to get that color. Can it be rgba(33, 37, 41, 0.03)
like the rest of of the card headers?
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.
agreed—and i created cityofaustin/atd-data-tech#20606 to follow-up on this 🙏
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.
Looks great + works great!
const localStorageValue = e !== null ? "0" : JSON.stringify(null); // local storage value must be a string type | ||
onSelect={(eventKey) => { | ||
const localStorageValue = | ||
eventKey !== null ? recordHistoryItemName : String(null); // local storage value must be a string type |
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.
nbd, but you can do away with the ternary and use String(eventKey)
as the localStorageValue
since it will always be null or the recordHistoryItemName
.
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.
+1 - i think that removing this ternary would make more readable 💯
}} | ||
> | ||
<Accordion.Item eventKey="0"> | ||
<Accordion.Header>Record history</Accordion.Header> |
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.
agreed—and i created cityofaustin/atd-data-tech#20606 to follow-up on this 🙏
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.
Thanks for making these adjustments! I retested, and I can still save my preferred layout. 🙌 🚀 🚢
Associated issues
Closes cityofaustin/atd-data-tech#19968
Testing
URL to test:
Local or netlify
Steps to test:
Ship list
main
branch