-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/react-18
- Loading branch information
Showing
173 changed files
with
6,494 additions
and
1,425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
'@twilio-paste/switch': major | ||
'@twilio-paste/core': major | ||
--- | ||
|
||
[Switch] Updated Switch component API to match other form components in Paste. | ||
|
||
- `SwitchContainer` has been replaced with `SwitchGroup` | ||
- `SwitchGroup` props changes: | ||
- removes `id?: string` | ||
- removes `label: ReactNode` - use the new `legend` prop instead. | ||
- adds `legend: string | NonNullable<React.ReactNode>` to replace the old `label` prop. | ||
- adds `errorText?: string | React.ReactNode` to handle error states. | ||
- adds `orientation?: 'vertical' | 'horizontal;` to set children orientation. | ||
- adds `i18nRequiredLabel?: string` to change the required label for internationalization. | ||
- adds `name: string` to label the switch group for forms. | ||
- adds `onChange?: (checked: boolean) => void` to handle changes to any child Switch's checked state in a single function. | ||
- `helpText` prop now accepts a string. | ||
- `required` prop is now optional. | ||
- `element` prop default value changed to `SWITCH_GROUP` from `SWITCH_CONTAINER` | ||
- `Switch` props changes: | ||
- `children` prop type changed to ` NonNullable<React.ReactNode>` | ||
- adds `hasError?: boolean` to handle error states. | ||
- adds `helpText?: string | React.React.Node` to add additional context to a switch. | ||
- adds `checked?: boolean` to use the Switch in a controlled manner. | ||
- adds `defaultChecked?: boolean` to set the default checked value in an uncontrolled manner. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as fs from 'fs'; | ||
import {getChangesetsFromFiles} from './utils'; | ||
// you kind of have to treat Danger plugins as global? | ||
// https://danger.systems/js/usage/extending-danger.html#writing-your-plugin | ||
import {DangerDSLType} from 'danger/distribution/dsl/DangerDSL'; | ||
declare const danger: DangerDSLType; | ||
export declare function fail(message: string): void; | ||
|
||
/** location in the repo where the upgrade guide lives */ | ||
export const UPGRADE_GUIDE_PAGE_FILE = 'packages/paste-website/src/pages/core/upgrade-guide.mdx'; | ||
|
||
export const FAIL_MESSAGE = `You have marked a Paste package as a MAJOR update via changeset, but have not provided a corresponding [upgrade guide](https://paste.twilio.design/core/upgrade-guide) entry. | ||
Please update the guide to inform our users what to do in response to this major update to Paste.`; | ||
|
||
/** | ||
* Check if the changeset file contents include a mention of a package major update | ||
* | ||
* @param {string} filePath | ||
* @return {*} | ||
*/ | ||
export const hasMajorUpdate = (filePath: string) => { | ||
const fileContent = fs.readFileSync(filePath).toString(); | ||
return /\@twilio-paste\/\S+: major/.test(fileContent); | ||
}; | ||
|
||
/** | ||
* Utility to return a list of changeset files that have listed a package as needing a major update | ||
* | ||
* @param {string[]} touchedChangesets | ||
* @return {*} {string[]} | ||
*/ | ||
export const getChangesetsWithMajorUpdate = (touchedChangesets: string[]): string[] => { | ||
return touchedChangesets.filter(hasMajorUpdate); | ||
}; | ||
|
||
/** | ||
* This is a Danger plugin that will fail if you have a changeset that sets a major version | ||
* update of a @twilio-paste/* package but do not also modify the Update Guide in the website. | ||
*/ | ||
export default () => { | ||
const modifiedChangeSets = getChangesetsFromFiles([...danger.git.modified_files, ...danger.git.created_files]); | ||
if (modifiedChangeSets.length === 0) return; | ||
|
||
const changesetsWithMajorUpdate = getChangesetsWithMajorUpdate(modifiedChangeSets); | ||
if (changesetsWithMajorUpdate.length === 0) return; | ||
|
||
const upgradeGuideChanged = danger.git.modified_files.includes(UPGRADE_GUIDE_PAGE_FILE); | ||
if (upgradeGuideChanged) return; | ||
|
||
fail(FAIL_MESSAGE); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,6 @@ out/ | |
|
||
.jest-coverage | ||
.jest-cache | ||
.jest-cache-react-16 | ||
**/lib/* | ||
**/dist/* | ||
packages/**/docs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.