|
| 1 | +--- |
| 2 | +title: Testimonial |
| 3 | +figma: 'https://www.figma.com/file/BJ95AjraesmRCWsKA013GS/Primer-Brand?node-id=1852%3A27522' |
| 4 | +source: https://github.com/primer/brand/blob/main/packages/react/src/Testimonial/Testimonial.tsx |
| 5 | +storybook: '/brand/storybook/?path=/story/components-testimonial' |
| 6 | +description: Use the testimonial component to display a quote from a customer or user. |
| 7 | +--- |
| 8 | + |
| 9 | +import ComponentLayout from '../../../src/layouts/component-layout' |
| 10 | +export default ComponentLayout |
| 11 | + |
| 12 | +import { |
| 13 | + TestimonialQuoteMarkColors, |
| 14 | + TestimonialVariants, |
| 15 | + defaultTestimonialVariant, |
| 16 | +} from '@primer/react-brand' |
| 17 | +import {Box as Container, Label} from '@primer/react' |
| 18 | +import {PropTableValues} from '../../../src/components' |
| 19 | + |
| 20 | +```js |
| 21 | +import {Testimonial} from '@primer/react-brand' |
| 22 | +``` |
| 23 | + |
| 24 | +## Examples |
| 25 | + |
| 26 | +### Default |
| 27 | + |
| 28 | +```jsx live |
| 29 | +<Testimonial> |
| 30 | + <Testimonial.Quote> |
| 31 | + GitHub helps us ensure that we have our security controls baked into our |
| 32 | + pipelines all the way from the first line of code we're writing. |
| 33 | + </Testimonial.Quote> |
| 34 | + <Testimonial.Name position="Staff Security Engineer"> |
| 35 | + David Ross |
| 36 | + </Testimonial.Name> |
| 37 | + <Testimonial.Avatar |
| 38 | + src="/brand/assets/avatar-mona.png" |
| 39 | + alt="Circular avatar from David Ross's GitHub profile" |
| 40 | + /> |
| 41 | +</Testimonial> |
| 42 | +``` |
| 43 | + |
| 44 | +### Variants |
| 45 | + |
| 46 | +For an alternative visual appearance and layout, without altering semantic meaning. |
| 47 | + |
| 48 | +```jsx live |
| 49 | +<Stack direction="horizontal" gap="spacious" padding="none"> |
| 50 | + <Testimonial variant="default"> |
| 51 | + <Testimonial.Quote> |
| 52 | + GitHub helps us ensure that we have our security controls baked into our |
| 53 | + pipelines all the way from the first line of code we're writing. |
| 54 | + </Testimonial.Quote> |
| 55 | + <Testimonial.Name position="Staff Security Engineer"> |
| 56 | + David Ross |
| 57 | + </Testimonial.Name> |
| 58 | + <Testimonial.Avatar |
| 59 | + src="/brand/assets/avatar-mona.png" |
| 60 | + alt="Circular avatar from David Ross's GitHub profile" |
| 61 | + /> |
| 62 | + </Testimonial> |
| 63 | + <Testimonial variant="subtle"> |
| 64 | + <Testimonial.Quote> |
| 65 | + GitHub helps us ensure that we have our security controls baked into our |
| 66 | + pipelines all the way from the first line of code we're writing. |
| 67 | + </Testimonial.Quote> |
| 68 | + <Testimonial.Name position="Staff Security Engineer"> |
| 69 | + David Ross |
| 70 | + </Testimonial.Name> |
| 71 | + <Testimonial.Avatar |
| 72 | + src="/brand/assets/avatar-mona.png" |
| 73 | + alt="Circular avatar from David Ross's GitHub profile" |
| 74 | + /> |
| 75 | + </Testimonial> |
| 76 | +</Stack> |
| 77 | +``` |
| 78 | + |
| 79 | +### Logo |
| 80 | + |
| 81 | +A logo (or similar) visual can be provided as an alternative to avatars. |
| 82 | + |
| 83 | +```jsx live |
| 84 | +<Testimonial> |
| 85 | + <Testimonial.Quote> |
| 86 | + GitHub helps us ensure that we have our security controls baked into our |
| 87 | + pipelines all the way from the first line of code we're writing. |
| 88 | + </Testimonial.Quote> |
| 89 | + <Testimonial.Name>David Ross</Testimonial.Name> |
| 90 | + <Testimonial.Logo> |
| 91 | + <img |
| 92 | + alt="GitHub Logo" |
| 93 | + src="https://github.githubassets.com/images/modules/logos_page/GitHub-Logo.png" |
| 94 | + width={60} |
| 95 | + /> |
| 96 | + </Testimonial.Logo> |
| 97 | +</Testimonial> |
| 98 | +``` |
| 99 | + |
| 100 | +### Size |
| 101 | + |
| 102 | +Use `size` to alternate the text size. Available options are `small` (default) and `large`. |
| 103 | + |
| 104 | +```jsx live |
| 105 | +<Testimonial size="large"> |
| 106 | + <Testimonial.Quote> |
| 107 | + GitHub helps us ensure that we have our security controls baked into our |
| 108 | + pipelines all the way from the first line of code we're writing. |
| 109 | + </Testimonial.Quote> |
| 110 | + <Testimonial.Name position="Staff Software Engineer"> |
| 111 | + David Ross |
| 112 | + </Testimonial.Name> |
| 113 | +</Testimonial> |
| 114 | +``` |
| 115 | + |
| 116 | +### Layout |
| 117 | + |
| 118 | +`Testimonial` will expand to fill the width of its parent by default. |
| 119 | + |
| 120 | +Use `Stack` to help position multiple, adjacent Testimonials alongside one another. |
| 121 | + |
| 122 | +```jsx live |
| 123 | +<Stack direction="horizontal" gap="spacious" padding="spacious"> |
| 124 | + <Testimonial> |
| 125 | + <Testimonial.Quote> |
| 126 | + GitHub helps us ensure that we have our security controls baked into our |
| 127 | + pipelines all the way from the first line of code we're writing. |
| 128 | + </Testimonial.Quote> |
| 129 | + <Testimonial.Name>David Ross</Testimonial.Name> |
| 130 | + </Testimonial> |
| 131 | + <Testimonial> |
| 132 | + <Testimonial.Quote> |
| 133 | + GitHub helps us ensure that we have our security controls baked into our |
| 134 | + pipelines all the way from the first line of code we're writing. |
| 135 | + </Testimonial.Quote> |
| 136 | + <Testimonial.Name>David Ross</Testimonial.Name> |
| 137 | + </Testimonial> |
| 138 | +</Stack> |
| 139 | +``` |
| 140 | + |
| 141 | +### Position |
| 142 | + |
| 143 | +Pass additional content about the testimonial provider using `position`. |
| 144 | + |
| 145 | +```jsx live |
| 146 | +<Testimonial> |
| 147 | + <Testimonial.Quote> |
| 148 | + GitHub helps us ensure that we have our security controls baked into our |
| 149 | + pipelines all the way from the first line of code we're writing. |
| 150 | + </Testimonial.Quote> |
| 151 | + <Testimonial.Name position="Staff Software Engineer"> |
| 152 | + David Ross |
| 153 | + </Testimonial.Name> |
| 154 | +</Testimonial> |
| 155 | +``` |
| 156 | + |
| 157 | +## Component props |
| 158 | + |
| 159 | +### Testimonial <Label>Required</Label> |
| 160 | + |
| 161 | +`Testimonial` passes contextual data to its child inputs, labels, validation messaging and more. |
| 162 | + |
| 163 | +| Name | Type | Default | Description | |
| 164 | +| :--------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------: | :-------------------------------------------- | |
| 165 | +| `children` | <PropTableValues addLineBreaks values={['Testimonial.Quote','Testimonial.Name','Testimonial.Logo','Testimonial.Avatar','React.ReactNode' ]} addLineBreaks /> | | Valid child nodes | |
| 166 | +| `className` | `string` | | Sets a custom class | |
| 167 | +| `id` | `string` | | Sets a custom id | |
| 168 | +| `ref` | `React.RefObject` | | Forward a Ref to the underlying DOM node | |
| 169 | +| `size` | <PropTableValues addLineBreaks values={['small','large']}/> | `'small'` | Set size of quote's text | |
| 170 | +| `quoteMarkColor` | <PropTableValues addLineBreaks values={TestimonialQuoteMarkColors}/> | `'default'` | Color or gradient fill of the the quote mark. | |
| 171 | +| `variant` | <PropTableValues addLineBreaks values={TestimonialVariants}/> | `'minimal'` | Alternative visual appearance | |
| 172 | + |
| 173 | +<h3 id="Testimonial-name"> |
| 174 | + Testimonial.Name <Label>Required</Label> |
| 175 | +</h3> |
| 176 | + |
| 177 | +`Testimonial.Name` indicates the name of the person (or organisation) that provided the testimonial. |
| 178 | + |
| 179 | +| Name | Type | Default | Description | |
| 180 | +| :---------- | :---------------- | :-----: | :------------------------------------------------------------------ | |
| 181 | +| `children` | `string` | | Label text | |
| 182 | +| `className` | `string` | | Applies a custom class | |
| 183 | +| `id` | `string` | | Sets a custom id | |
| 184 | +| `ref` | `React.RefObject` | | Forward a Ref to the underlying DOM node | |
| 185 | +| `position` | `string` | | Optional. Applies additional content adjancent to the primary text. | |
| 186 | + |
| 187 | +<h3 id="Testimonial-avatar">Testimonial.Avatar</h3> |
| 188 | + |
| 189 | +`Testimonial.Avatar` represent users or organizations. |
| 190 | + |
| 191 | +| Name | Type | Default | Description | |
| 192 | +| :---------- | :---------------- | :-----: | :----------------------------------------------------------------- | |
| 193 | +| `children` | `string` | | Label text | |
| 194 | +| `className` | `string` | | Applies a custom class | |
| 195 | +| `id` | `string` | | Sets a custom id | |
| 196 | +| `ref` | `React.RefObject` | | Forward a Ref to the underlying DOM node | |
| 197 | +| `src` | `string` | | Required. A url to the user or organisations GitHub profile avatar | |
| 198 | +| `alt` | `string` | | Required. Applied as alt text to the avatar. | |
| 199 | + |
| 200 | +<h3 id="Testimonial-logo">Testimonial.Logo</h3> |
| 201 | + |
| 202 | +`Testimonial.Logo` passes a visual that represents the users or organizations. |
| 203 | + |
| 204 | +| Name | Type | Default | Description | |
| 205 | +| :---------- | :---------------------------------------------------------------------------- | :-----: | :----------------------------------------------------- | |
| 206 | +| `children` | <PropTableValues addLineBreaks values={['SVGElement', 'HTMLImageElement']} /> | | Accepts `<img>` and `<svg>` HTML elements as children. | |
| 207 | +| `className` | `string` | | Applies a custom class | |
| 208 | +| `id` | `string` | | Sets a custom id | |
| 209 | +| `ref` | `React.RefObject` | | Forward a Ref to the underlying DOM node | |
0 commit comments