Skip to content

Commit

Permalink
chore: inject core version into the DOM (#3173)
Browse files Browse the repository at this point in the history
* chore: inject core version into the DOM

* chore: snapshots
  • Loading branch information
SiTaggart committed Apr 20, 2023
1 parent d1d3088 commit e801b77
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .changeset/thirty-games-protect.md
@@ -0,0 +1,7 @@
---
'@twilio-paste/box': patch
'@twilio-paste/text': patch
'@twilio-paste/core': patch
---

[Box, Text]: inject the Paste Core version into the DOM for better debugging in consumer applications and remote inspection
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -156,6 +156,7 @@
"danger": "^10.6.6",
"dotenv": "^16.0.0",
"esbuild": "^0.15.18",
"esbuild-plugin-version-injector": "^1.1.0",
"eslint": "^8.29.0",
"eslint-config-prettier": "8.5.0",
"eslint-config-twilio-react": "2.0.0",
Expand Down
Expand Up @@ -53,11 +53,13 @@ exports[`Avatar image should render responsive css with an image 1`] = `
<div
class="emotion-0"
data-paste-core-version="19.0.1"
data-paste-element="AVATAR"
>
<img
alt="avatar example"
class="emotion-1"
data-paste-core-version="19.0.1"
data-paste-element="BOX"
src="/avatars/avatar2.png"
title="avatar example"
Expand Down Expand Up @@ -126,10 +128,12 @@ exports[`Avatar intials should render responsive css 1`] = `
<div
class="emotion-0"
data-paste-core-version="19.0.1"
data-paste-element="AVATAR"
>
<abbr
class="emotion-1"
data-paste-core-version="19.0.1"
data-paste-element="TEXT"
title="Simon Taggart"
>
Expand Down
Expand Up @@ -31,6 +31,7 @@ exports[`Separator Render should set horizontal margins 1`] = `
<hr
aria-orientation="horizontal"
class="emotion-1"
data-paste-core-version="19.0.1"
data-paste-element="SEPARATOR"
/>
</div>
Expand Down Expand Up @@ -82,6 +83,7 @@ exports[`Separator Render should set responsive horizontal margins 1`] = `
<hr
aria-orientation="horizontal"
class="emotion-1"
data-paste-core-version="19.0.1"
data-paste-element="SEPARATOR"
/>
</div>
Expand Down Expand Up @@ -133,6 +135,7 @@ exports[`Separator Render should set responsive vertical margins 1`] = `
<hr
aria-orientation="vertical"
class="emotion-1"
data-paste-core-version="19.0.1"
data-paste-element="SEPARATOR"
/>
</div>
Expand Down Expand Up @@ -170,6 +173,7 @@ exports[`Separator Render should set vertical margins 1`] = `
<hr
aria-orientation="vertical"
class="emotion-1"
data-paste-core-version="19.0.1"
data-paste-element="SEPARATOR"
/>
</div>
Expand Down
Expand Up @@ -13,6 +13,7 @@ exports[`Grid render should render a Column 1`] = `
<div
class="emotion-0"
data-paste-core-version="19.0.1"
data-paste-element="COLUMN"
>
child
Expand All @@ -39,6 +40,7 @@ exports[`Grid render should render a Grid 1`] = `
<div
class="emotion-0"
data-paste-core-version="19.0.1"
data-paste-element="GRID"
>
child
Expand All @@ -65,6 +67,7 @@ exports[`Grid render should render a Grid as any HTML element 1`] = `
<section
class="emotion-0"
data-paste-core-version="19.0.1"
data-paste-element="GRID"
>
child
Expand Down Expand Up @@ -174,14 +177,17 @@ exports[`Grid render should render responsive css 1`] = `
<div
class="emotion-0"
data-paste-core-version="19.0.1"
data-paste-element="GRID"
>
<div
class="emotion-1"
data-paste-core-version="19.0.1"
data-paste-element="COLUMN"
/>
<div
class="emotion-2"
data-paste-core-version="19.0.1"
data-paste-element="COLUMN"
/>
</div>
Expand Down
4 changes: 3 additions & 1 deletion packages/paste-core/primitives/box/src/index.tsx
Expand Up @@ -21,6 +21,8 @@ import {getPseudoStyles, PasteStyleProps, getCustomElementStyles} from './StyleF
import {customStyleProps} from './CustomStyleProps';
import {PseudoPropStyles} from './PseudoPropStyles';

const coreVersionNumberPlaceholder: string = '[VI]{{inject}}[/VI]';

// we need size to hit the DOM for <select /> elements
const stylingPropsWithoutSize = defaultStylingProps.filter((item: string) => item !== 'size');

Expand All @@ -45,7 +47,7 @@ export const StyledBox = styled('div', {shouldForwardProp})<StyledBoxProps>(

const Box = React.forwardRef<HTMLElement, BoxProps>(({children, element = 'BOX', ...props}, ref) => {
return (
<StyledBox data-paste-element={element} ref={ref} {...props}>
<StyledBox data-paste-element={element} data-paste-core-version={coreVersionNumberPlaceholder} ref={ref} {...props}>
{children}
</StyledBox>
);
Expand Down
Expand Up @@ -100,6 +100,7 @@ input[type=checkbox][aria-invalid=true]+label .emotion-1 {
<div
aria-hidden="true"
class="emotion-1"
data-paste-core-version="19.0.1"
data-paste-element="SIBLING_BOX"
>
child
Expand Down

0 comments on commit e801b77

Please sign in to comment.