-
Notifications
You must be signed in to change notification settings - Fork 35
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
Update to Storybook v6, add base TypeScript support at project level and add typings for two packages #250
Conversation
@evansiroky, let's just bump to Storybook 6 in that case? Unless the migration is overly cumbersome? |
@@ -1,4 +1,4 @@ | |||
import React from "react"; |
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 story is not being shown in Storybook. Add the .story.tsx
extension to /.storybook/config.js
.
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.
Upgrading storybook doesn't look straight forward and will need some more investigation.
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.
If no objections, I'm going to merge in #242 and then deploy Storybook of latest 'dev' to the github pages site.
Ready for review again, this time with an update to Storybook v6. |
@@ -0,0 +1,14 @@ | |||
import React from "react"; |
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.
Is there not a way to output the leg- and mode-icon stories as they previously were handled? This new code just seems like a lot of extra files/boilerplate.
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 agree to the extent that some of the related code is a bit overkill and not directly related to the PR, although I like the grouping by each LegIcon
and ModeIcon
component.
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.
There is not a way to output as they were before since there is no way to dynamically generate a lot of stories once storiesOf
is deprecated. See storybookjs/storybook#9828. The previous way was also quite difficult to browse and somewhat meaningless. This new method shows the output of the various LegIcon and ModeIcon components which I feel is an improvement.
export const MenuItemA = styled.a` | ||
background-color: ${props => (props.active ? "#337ab7" : "transparent")}; | ||
clear: both; | ||
color: ${props => (props.active ? "#fff" : "#333")}; | ||
display: block; | ||
font-weight: 400; | ||
line-height: 1.42857143; | ||
padding: 3px 20px; | ||
text-decoration: none; | ||
white-space: nowrap; | ||
`; | ||
|
||
export const MenuItemHeader = styled.li` | ||
color: navy; | ||
display: block; | ||
font-size: 14px; | ||
font-weight: 600; | ||
line-height: 1.42857143; | ||
padding: 3px 20px; | ||
text-align: ${props => (props.centeredText ? "center" : "left")}; | ||
white-space: nowrap; | ||
`; | ||
|
||
export const MenuItemLi = styled.li` | ||
&:hover { | ||
background-color: ${props => !props.disabled && "#f5f5f5"}; | ||
} | ||
`; | ||
|
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.
Are these components just moved around this file? If so, I don't fully understand why?
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.
As part of updating the eslint config, the new rule of no-use-before-define
became active. The moving around of these variables is to comply with this new rule.
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.
|
||
addons.setConfig({ | ||
sidebar: { | ||
showRoots: false |
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.
What does this setting do? (probably needs a comment if we are overriding a default)
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.
Added a comment in 2695404
babel.config.js
Outdated
"babel-plugin-styled-components" | ||
], | ||
presets: [ | ||
["@babel/preset-env", { targets: { node: "current" } }], | ||
["@babel/preset-typescript"], |
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.
Remove array notation if we are not passing extra params.
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.
Refactored in 2695404
@@ -0,0 +1,14 @@ | |||
import React from "react"; |
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 agree to the extent that some of the related code is a bit overkill and not directly related to the PR, although I like the grouping by each LegIcon
and ModeIcon
component.
const bikeOnlyItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-only.json"); | ||
const bikeRentalItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-rental.json"); | ||
const eScooterRentalItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/e-scooter-rental.json"); | ||
const parkAndRideItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/park-and-ride.json"); | ||
const tncTransitTncItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/tnc-transit-tnc.json"); | ||
const walkOnlyItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-only.json"); | ||
const walkTransitWalkItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-transit-walk.json"); | ||
const walkTransitWalkTransitWalkItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-transit-walk-transit-walk.json"); | ||
|
||
const exampleLegs = [ | ||
{ leg: bikeOnlyItinerary.legs[0], type: "Personal bike" }, | ||
{ leg: bikeRentalItinerary.legs[1], type: "Bike rental" }, | ||
{ leg: walkTransitWalkTransitWalkItinerary.legs[1], type: "Bus" }, | ||
{ | ||
leg: eScooterRentalItinerary.legs[1], | ||
type: "Micromobility (from Razor company)" | ||
}, | ||
{ leg: parkAndRideItinerary.legs[0], type: "Park & Ride" }, | ||
{ leg: tncTransitTncItinerary.legs[0], type: "TNC (Uber)" }, | ||
{ leg: walkTransitWalkItinerary.legs[1], type: "Tram" }, | ||
{ leg: walkOnlyItinerary.legs[0], type: "Walk" } | ||
]; |
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.
Importing an entire leg seems overkill. But maybe that comes from the redundancy between ModeIcon
and LegIcon
, so should we address #27 in the near future?
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.
The leg is needed because it is an input into a LegIcon component.
I'm not sure how this related to #27. I believe we may have already resolved it by have a TriMetLegIcon, ClassicLegIcon and StandardLegIcon classes.
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.
Might be for another discussion... if we addressed #27 you wouldn't have to load all of these itineraries just to extract one leg and ultimately the mode for that leg.
This is the first of many PRs to add TypeScript types throughout this project. This first PR sets up the overall project to be able to handle TypeScript in the first place. As a part of adding TypeScript, Storybook was also updated to v6 to be able to take advantage of the automatic generation of Storybook documentation from type definitions.
This PR does the following specifically:
Project-wide changes
Typescript stuff
airbnb
toairbnb-typescript
, adding the @typescript-eslint/recommended plugin, and substituting a few common eslint checks for TypeScript-friendly checks. (see more info on this as it might come up later).Storybook stuff
addon-info
withaddon-docs
) (fixes Storybook: look to switch from addon-info to addon-docs #68, fixes Storybook: upgrade to v6 #187).{ loose: true }
).storiesOf
stories into CSF format.Changes to base-map package
Changes to humanize-duration package
Changes to icons package
Changes to itinerary-body package
Changes to location-field package
Changes to location-icon package