-
Notifications
You must be signed in to change notification settings - Fork 115
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/minimizable-dialog
- Loading branch information
Showing
149 changed files
with
2,515 additions
and
429 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,6 @@ | ||
--- | ||
'@twilio-paste/label': minor | ||
'@twilio-paste/core': minor | ||
--- | ||
|
||
[Label] add the ability to use the label as a div HTML element |
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,6 @@ | ||
--- | ||
'@twilio-paste/switch': major | ||
'@twilio-paste/core': minor | ||
--- | ||
|
||
[Switch] add Switch package |
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,6 @@ | ||
--- | ||
'@twilio-paste/core': patch | ||
'@twilio-paste/theme': patch | ||
--- | ||
|
||
[Theme] add new icon size (05) to theme shape |
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,6 @@ | ||
--- | ||
'@twilio-paste/core': patch | ||
'@twilio-paste/box': patch | ||
--- | ||
|
||
[Box] add a `_checked_hover` pseudo selector style prop for use in switch package |
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,6 @@ | ||
--- | ||
'@twilio-paste/core': minor | ||
'@twilio-paste/design-tokens': minor | ||
--- | ||
|
||
[Design tokens] add new icon size and line height tokens (05), adust dark theme background tokens |
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,6 @@ | ||
--- | ||
'@twilio-paste/alert': patch | ||
'@twilio-paste/core': patch | ||
--- | ||
|
||
[Alert] add screen-reader-only as peerDependency |
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,6 @@ | ||
--- | ||
'@twilio-paste/menu': minor | ||
'@twilio-paste/core': minor | ||
--- | ||
|
||
- [menu] add menu item destructive variant |
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,6 @@ | ||
--- | ||
'@twilio-paste/callout': major | ||
'@twilio-paste/core': minor | ||
--- | ||
|
||
[Callout] Introducing the all-new Callout component! This component is useful in those moments when you want to highlight important - yet static - information in a page of text. 🎉 |
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 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,13 @@ | ||
# Adding New Design Tokens | ||
|
||
Tokens live in `packages/paste-design-tokens/tokens/global`. Dark theme tokens live in `packages/paste-design-tokens/tokens/dark/global`. | ||
|
||
After adding a new token, bump the package and core up as a minor by running `yarn changeset`. | ||
|
||
## Colors | ||
|
||
When adding new color tokens, make sure the value points to an alias (e.g. `red-60`). | ||
|
||
## Icon sizes | ||
|
||
Make sure the new icon size points to a line height. You may have to add a new token to fit your needs. You'll also have to add the new line height to the alias file. You'll also need to add the new icon size to the `packages/paste-theme/src/generateThemeFromTokens` file and the `packages/paste-theme/src/types/GenericThemeShape` file. That will require a re-build and a snapshot update for the theme shape. |
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 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
# Change Log |
213 changes: 213 additions & 0 deletions
213
packages/paste-core/components/callout/__tests__/customization.spec.tsx
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,213 @@ | ||
import * as React from 'react'; | ||
import {render, screen} from '@testing-library/react'; | ||
import {CustomizationProvider} from '@twilio-paste/customization'; | ||
|
||
import {Callout, CalloutHeading, CalloutList, CalloutListItem, CalloutText} from '../src'; | ||
|
||
const CustomizationWrapper: React.FC = ({children}) => ( | ||
<CustomizationProvider | ||
baseTheme="default" | ||
theme={TestTheme} | ||
elements={{ | ||
CALLOUT: { | ||
padding: 'space40', | ||
variants: { | ||
neutral: { | ||
backgroundColor: 'colorBackgroundBodyInverse', | ||
color: 'colorTextInverse', | ||
}, | ||
warning: { | ||
backgroundColor: 'colorBackground', | ||
color: 'colorTextWarningStrong', | ||
borderStyle: 'solid', | ||
borderWidth: 'borderWidth20', | ||
borderColor: 'colorBorderWarning', | ||
}, | ||
}, | ||
}, | ||
CALLOUT_HEADING: { | ||
fontSize: 'fontSize50', | ||
lineHeight: 'lineHeight50', | ||
}, | ||
CALLOUT_TEXT: { | ||
fontSize: 'fontSize30', | ||
lineHeight: 'lineHeight30', | ||
}, | ||
CALLOUT_LIST: { | ||
marginLeft: 'space50', | ||
}, | ||
CALLOUT_LIST_ITEM: { | ||
fontSize: 'fontSize30', | ||
lineHeight: 'lineHeight30', | ||
}, | ||
}} | ||
> | ||
{children} | ||
</CustomizationProvider> | ||
); | ||
|
||
const MyCustomizationWrapper: React.FC = ({children}) => ( | ||
<CustomizationProvider | ||
baseTheme="default" | ||
theme={TestTheme} | ||
elements={{ | ||
FOO_CALLOUT: { | ||
padding: 'space40', | ||
variants: { | ||
neutral: { | ||
backgroundColor: 'colorBackgroundBodyInverse', | ||
color: 'colorTextInverse', | ||
}, | ||
warning: { | ||
backgroundColor: 'colorBackground', | ||
color: 'colorTextWarningStrong', | ||
borderStyle: 'solid', | ||
borderWidth: 'borderWidth20', | ||
borderColor: 'colorBorderWarning', | ||
}, | ||
}, | ||
}, | ||
FOO_CALLOUT_HEADING: { | ||
fontSize: 'fontSize50', | ||
lineHeight: 'lineHeight50', | ||
}, | ||
FOO_CALLOUT_TEXT: { | ||
fontSize: 'fontSize30', | ||
lineHeight: 'lineHeight30', | ||
}, | ||
FOO_CALLOUT_LIST: { | ||
marginLeft: 'space50', | ||
}, | ||
FOO_CALLOUT_LIST_ITEM: { | ||
fontSize: 'fontSize30', | ||
lineHeight: 'lineHeight30', | ||
}, | ||
}} | ||
> | ||
{children} | ||
</CustomizationProvider> | ||
); | ||
|
||
describe('Customization', () => { | ||
it('should set a default element data attribute', () => { | ||
render( | ||
<Callout variant="neutral" data-testid="callout"> | ||
<CalloutHeading as="h3">Neutral callout</CalloutHeading> | ||
<CalloutText data-testid="callout-text">Take a look at this list:</CalloutText> | ||
<CalloutList as="ul"> | ||
<CalloutListItem>Item one</CalloutListItem> | ||
</CalloutList> | ||
</Callout> | ||
); | ||
|
||
const callout = screen.getByTestId('callout'); | ||
const heading = screen.getByRole('heading', {name: 'Neutral callout'}); | ||
const text = screen.getByTestId('callout-text'); | ||
const list = screen.getByRole('list'); | ||
const listItem = screen.getByRole('listitem'); | ||
|
||
expect(callout.getAttribute('data-paste-element')).toEqual('CALLOUT'); | ||
expect(heading.getAttribute('data-paste-element')).toEqual('CALLOUT_HEADING'); | ||
expect(text.getAttribute('data-paste-element')).toEqual('CALLOUT_TEXT'); | ||
expect(list.getAttribute('data-paste-element')).toEqual('CALLOUT_LIST'); | ||
expect(listItem.getAttribute('data-paste-element')).toEqual('CALLOUT_LIST_ITEM'); | ||
}); | ||
|
||
it('should set a custom element data attribute', () => { | ||
render( | ||
<Callout variant="neutral" data-testid="callout" element="FOO_CALLOUT"> | ||
<CalloutHeading as="h3" element="FOO_CALLOUT_HEADING"> | ||
Neutral callout | ||
</CalloutHeading> | ||
<CalloutText data-testid="callout-text" element="FOO_CALLOUT_TEXT"> | ||
Take a look at this list: | ||
</CalloutText> | ||
<CalloutList as="ul" element="FOO_CALLOUT_LIST"> | ||
<CalloutListItem element="FOO_CALLOUT_LIST_ITEM">Item one</CalloutListItem> | ||
</CalloutList> | ||
</Callout> | ||
); | ||
|
||
const callout = screen.getByTestId('callout'); | ||
const heading = screen.getByRole('heading', {name: 'Neutral callout'}); | ||
const text = screen.getByTestId('callout-text'); | ||
const list = screen.getByRole('list'); | ||
const listItem = screen.getByRole('listitem'); | ||
|
||
expect(callout.getAttribute('data-paste-element')).toEqual('FOO_CALLOUT'); | ||
expect(heading.getAttribute('data-paste-element')).toEqual('FOO_CALLOUT_HEADING'); | ||
expect(text.getAttribute('data-paste-element')).toEqual('FOO_CALLOUT_TEXT'); | ||
expect(list.getAttribute('data-paste-element')).toEqual('FOO_CALLOUT_LIST'); | ||
expect(listItem.getAttribute('data-paste-element')).toEqual('FOO_CALLOUT_LIST_ITEM'); | ||
}); | ||
|
||
it('should add custom styles to the components', () => { | ||
render( | ||
<> | ||
<Callout variant="neutral" data-testid="neutral-callout"> | ||
<CalloutHeading as="h3">Neutral callout</CalloutHeading> | ||
<CalloutText data-testid="callout-text">Take a look at this list:</CalloutText> | ||
<CalloutList as="ul"> | ||
<CalloutListItem>Item one</CalloutListItem> | ||
</CalloutList> | ||
</Callout> | ||
<Callout variant="warning" data-testid="warning-callout"> | ||
<CalloutText>This is a warning callout</CalloutText> | ||
</Callout> | ||
</>, | ||
{wrapper: CustomizationWrapper} | ||
); | ||
|
||
const neutralCallout = screen.getByTestId('neutral-callout'); | ||
const warningCallout = screen.getByTestId('neutral-callout'); | ||
const heading = screen.getByRole('heading', {name: 'Neutral callout'}); | ||
const text = screen.getByTestId('callout-text'); | ||
const list = screen.getByRole('list'); | ||
const listItem = screen.getByRole('listitem'); | ||
|
||
expect(neutralCallout).toHaveStyleRule('padding', '0.75rem'); | ||
expect(neutralCallout).toHaveStyleRule('background-color', 'rgb(18, 28, 45)'); | ||
expect(warningCallout).toHaveStyleRule('background-color', 'rgb(18, 28, 45)'); | ||
expect(heading).toHaveStyleRule('font-size', '1.125rem'); | ||
expect(text).toHaveStyleRule('font-size', '0.875rem'); | ||
expect(list).toHaveStyleRule('margin-left', '1rem'); | ||
expect(listItem).toHaveStyleRule('font-size', '0.875rem'); | ||
}); | ||
|
||
it('shoult add custom styles to the components with custom element names', () => { | ||
render( | ||
<> | ||
<Callout variant="neutral" data-testid="neutral-callout" element="FOO_CALLOUT"> | ||
<CalloutHeading as="h3" element="FOO_CALLOUT_HEADING"> | ||
Neutral callout | ||
</CalloutHeading> | ||
<CalloutText data-testid="callout-text" element="FOO_CALLOUT_TEXT"> | ||
Take a look at this list: | ||
</CalloutText> | ||
<CalloutList as="ul" element="FOO_CALLOUT_LIST"> | ||
<CalloutListItem element="FOO_CALLOUT_LIST_ITEM">Item one</CalloutListItem> | ||
</CalloutList> | ||
</Callout> | ||
<Callout variant="warning" data-testid="warning-callout" element="FOO_CALLOUT"> | ||
<CalloutText element="FOO_CALLOUT_TEXT">This is a warning callout</CalloutText> | ||
</Callout> | ||
</>, | ||
{wrapper: MyCustomizationWrapper} | ||
); | ||
|
||
const neutralCallout = screen.getByTestId('neutral-callout'); | ||
const warningCallout = screen.getByTestId('neutral-callout'); | ||
const heading = screen.getByRole('heading', {name: 'Neutral callout'}); | ||
const text = screen.getByTestId('callout-text'); | ||
const list = screen.getByRole('list'); | ||
const listItem = screen.getByRole('listitem'); | ||
|
||
expect(neutralCallout).toHaveStyleRule('padding', '0.75rem'); | ||
expect(neutralCallout).toHaveStyleRule('background-color', 'rgb(18, 28, 45)'); | ||
expect(warningCallout).toHaveStyleRule('background-color', 'rgb(18, 28, 45)'); | ||
expect(heading).toHaveStyleRule('font-size', '1.125rem'); | ||
expect(text).toHaveStyleRule('font-size', '0.875rem'); | ||
expect(list).toHaveStyleRule('margin-left', '1rem'); | ||
expect(listItem).toHaveStyleRule('font-size', '0.875rem'); | ||
}); | ||
}); |
Oops, something went wrong.