Skip to content

Commit 96a3823

Browse files
author
Eric Olkowski
committed
Added new modifier class to clipboard copy
1 parent 7eb520b commit 96a3823

File tree

11 files changed

+67
-21
lines changed

11 files changed

+67
-21
lines changed

packages/react-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"tslib": "^2.8.1"
5555
},
5656
"devDependencies": {
57-
"@patternfly/patternfly": "6.2.0-prerelease.20",
57+
"@patternfly/patternfly": "6.2.0-prerelease.21",
5858
"case-anything": "^3.1.2",
5959
"css": "^3.0.0",
6060
"fs-extra": "^11.3.0"

packages/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Fragment } from 'react';
1+
import { Component, Fragment, createRef } from 'react';
22
import styles from '@patternfly/react-styles/css/components/ClipboardCopy/clipboard-copy';
33
import { css } from '@patternfly/react-styles';
44
import { PickOptional } from '../../helpers/typeUtils';
@@ -115,7 +115,7 @@ class ClipboardCopy extends Component<ClipboardCopyProps, ClipboardCopyState> {
115115
textWhenExpanded: text
116116
};
117117

118-
this.clipboardRef = React.createRef();
118+
this.clipboardRef = createRef();
119119
}
120120

121121
static defaultProps: PickOptional<ClipboardCopyProps> = {
@@ -219,6 +219,7 @@ class ClipboardCopy extends Component<ClipboardCopyProps, ClipboardCopyState> {
219219
variant === ClipboardCopyVariant.inlineCompact && styles.modifiers.inline,
220220
isBlock && styles.modifiers.block,
221221
this.state.expanded && styles.modifiers.expanded,
222+
shouldTruncate && styles.modifiers.truncate,
222223
className
223224
)}
224225
ref={this.clipboardRef}

packages/react-core/src/components/ClipboardCopy/__tests__/ClipboardCopy.test.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,52 @@ test(`Renders with class ${styles.modifiers.block} when isBlock is passed`, () =
105105
expect(screen.getByTestId(testId)).toHaveClass(styles.modifiers.block);
106106
});
107107

108+
test(`Does not render with class ${styles.modifiers.truncate} by default`, () => {
109+
render(<ClipboardCopy data-testid={testId}>{children}</ClipboardCopy>);
110+
111+
expect(screen.getByTestId(testId)).not.toHaveClass(styles.modifiers.truncate);
112+
});
113+
114+
test(`Does not render with class ${styles.modifiers.truncate} for expansion variant`, () => {
115+
render(
116+
<ClipboardCopy variant={ClipboardCopyVariant.expansion} data-testid={testId}>
117+
{children}
118+
</ClipboardCopy>
119+
);
120+
121+
expect(screen.getByTestId(testId)).not.toHaveClass(styles.modifiers.truncate);
122+
});
123+
124+
test(`Does not render with class ${styles.modifiers.truncate} for inlinecompact variant and truncation is false`, () => {
125+
render(
126+
<ClipboardCopy variant={ClipboardCopyVariant.inlineCompact} data-testid={testId}>
127+
{children}
128+
</ClipboardCopy>
129+
);
130+
131+
expect(screen.getByTestId(testId)).not.toHaveClass(styles.modifiers.truncate);
132+
});
133+
134+
test(`Renders with class ${styles.modifiers.truncate} when truncation is true and variant is inline-compact`, () => {
135+
render(
136+
<ClipboardCopy variant={ClipboardCopyVariant.inlineCompact} truncation data-testid={testId}>
137+
{children}
138+
</ClipboardCopy>
139+
);
140+
141+
expect(screen.getByTestId(testId)).toHaveClass(styles.modifiers.truncate);
142+
});
143+
144+
test(`Renders with class ${styles.modifiers.truncate} when truncation is an object and variant is inlinecompact`, () => {
145+
render(
146+
<ClipboardCopy variant={ClipboardCopyVariant.inlineCompact} truncation={{}} data-testid={testId}>
147+
{children}
148+
</ClipboardCopy>
149+
);
150+
151+
expect(screen.getByTestId(testId)).toHaveClass(styles.modifiers.truncate);
152+
});
153+
108154
test('Spreads additional props to container div', () => {
109155
render(
110156
<ClipboardCopy data-testid={testId} role="group">

packages/react-core/src/components/ClipboardCopy/__tests__/__snapshots__/ClipboardCopy.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exports[`Matches snapshot 1`] = `
1818
<input
1919
aria-invalid="false"
2020
aria-label="Copyable input"
21-
data-ouia-component-id="OUIA-Generated-TextInputBase-28"
21+
data-ouia-component-id="OUIA-Generated-TextInputBase-30"
2222
data-ouia-component-type="PF6/TextInput"
2323
data-ouia-safe="true"
2424
id="text-input-generated-id"

packages/react-core/src/components/ClipboardCopy/examples/ClipboardCopy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
6666
```ts file="./ClipboardCopyInlineCompactInSentence.tsx"
6767
```
6868

69-
### With truncation
69+
### Inline compact with truncation
7070

7171
You can control the truncation for an `inline-compact` variant by passing the `truncation` property. The following example shows the different ways to use the property: passing a boolean will apply default truncation, while passing an object of `TruncateProps` offers more fine-tuned control over the truncation behavior.
7272

73-
```ts file="./ClipboardCopyTruncation.tsx"
73+
```ts file="./ClipboardCopyInlineCompactTruncation.tsx"
7474
```

packages/react-core/src/components/ClipboardCopy/examples/ClipboardCopyTruncation.tsx renamed to packages/react-core/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactTruncation.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import React from 'react';
21
import { ClipboardCopy } from '@patternfly/react-core';
3-
export const ClipboardCopyTruncation: React.FunctionComponent = () => (
2+
export const ClipboardCopyInlineCompactTruncation: React.FunctionComponent = () => (
43
<>
54
<ClipboardCopy truncation hoverTip="Copy" clickTip="Copied" variant="inline-compact">
65
This lengthy, copyable content will be truncated with default settings when the truncation prop is simply set to

packages/react-docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"test:a11y": "patternfly-a11y --config patternfly-a11y.config"
2424
},
2525
"dependencies": {
26-
"@patternfly/patternfly": "6.2.0-prerelease.20",
26+
"@patternfly/patternfly": "6.2.0-prerelease.21",
2727
"@patternfly/react-charts": "workspace:^",
2828
"@patternfly/react-code-editor": "workspace:^",
2929
"@patternfly/react-core": "workspace:^",

packages/react-icons/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@fortawesome/free-brands-svg-icons": "^5.15.4",
3434
"@fortawesome/free-regular-svg-icons": "^5.15.4",
3535
"@fortawesome/free-solid-svg-icons": "^5.15.4",
36-
"@patternfly/patternfly": "6.2.0-prerelease.20",
36+
"@patternfly/patternfly": "6.2.0-prerelease.21",
3737
"fs-extra": "^11.3.0",
3838
"tslib": "^2.8.1"
3939
},

packages/react-styles/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"clean": "rimraf dist css"
2020
},
2121
"devDependencies": {
22-
"@patternfly/patternfly": "6.2.0-prerelease.20",
22+
"@patternfly/patternfly": "6.2.0-prerelease.21",
2323
"change-case": "^5.4.4",
2424
"fs-extra": "^11.3.0"
2525
},

packages/react-tokens/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"clean": "rimraf dist"
3030
},
3131
"devDependencies": {
32-
"@patternfly/patternfly": "6.2.0-prerelease.20",
32+
"@patternfly/patternfly": "6.2.0-prerelease.21",
3333
"css": "^3.0.0",
3434
"fs-extra": "^11.3.0"
3535
}

0 commit comments

Comments
 (0)