-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ref(platforms): Improve implementation of platformRegistry #7505
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
ref(platforms): Improve implementation of platformRegistry #7505
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
} | ||
`; | ||
|
||
export const formatCaseStyle = (style: string, value: string): string => { |
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.
Didn't make sense for this to be exported in usePlatforms
.
// community, | ||
// } | ||
|
||
export type Guide = { |
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.
Moved to a types file
c904066
to
b5271ee
Compare
// platform might actually not be a platform, so lets handle that case gracefully | ||
if (!(currentPlatform as Platform).guides) { | ||
|
||
if (currentPlatform.type === 'guide') { |
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.
We're now able to discriminate on the type
property to indicate if it's a platform or a platform guide. This is a lot cleaner.
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.
Everything is typed much better in here, making a bit more clear the distinction between a Platform
and a PlatformGuide
.
b5271ee
to
48d64b4
Compare
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 data model is a little confusing here, but that's not really anything as far as this PR is concerned. LGTM, thanks! Just a buncha typos
}; | ||
|
||
export function GuideGrid({platform, className}: Props) { | ||
const [currentPlatform] = usePlatform(platform); |
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 little confusing that usePlatform
might return a guide, but I guess that's just the data model?
src/shared/platformRegistry.ts
Outdated
} from '../types'; | ||
|
||
/** | ||
* Common default values that all platform configs will recieve (but may be |
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.
* Common default values that all platform configs will recieve (but may be | |
* Common default values that all platform configs will receive (but may be |
src/shared/platformRegistry.ts
Outdated
this._keyMap = {}; | ||
/** | ||
* When the given config object has a fallbackPlatform, this will ensure the | ||
* `propegatedConfig` keys are present with their values from the |
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.
* `propegatedConfig` keys are present with their values from the | |
* `propagatedConfig` keys are present with their values from the |
src/shared/platformRegistry.ts
Outdated
} | ||
|
||
/** | ||
* Constructs the patlform registry mapping object. |
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.
* Constructs the patlform registry mapping object. | |
* Constructs the platform registry mapping object. |
e285f45
to
ed5afe3
Compare
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 hurt my brain a little, but I'm on board that this refactor helps
This change simplfies the PlatformRegistry
ed5afe3
to
35dc377
Compare
This change simplfies the PlatformRegistry
This change simplifies the
PlatformRegistry
in various ways. I will leave inline comments on the PR.