Debian Codegraph @

node/@patternfly/patternfly/docs/components/CodeBlock/examples/CodeBlock.md

raw
1 ---
2 id: 'Code block'
3 section: components
4 cssPrefix: pf-v6-c-code-block
5 ---## Examples
6
7 ### Basic
8
9 ```html
10 <div class="pf-v6-c-code-block">
11 <div class="pf-v6-c-code-block__header">
12 <div class="pf-v6-c-code-block__actions">
13 <div class="pf-v6-c-code-block__actions-item">
14 <button
15 class="pf-v6-c-button pf-m-plain"
16 type="button"
17 aria-label="Copy to clipboard basic example code content"
18 >
19 <span class="pf-v6-c-button__icon">
20 <svg
21 class="pf-v6-svg"
22 fill="currentColor"
23 viewBox="0 0 448 512"
24 aria-hidden="true"
25 role="img"
26 width="1em"
27 height="1em"
28 >
29 <path
30 d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
31 />
32 </svg>
33 </span>
34 </button>
35 </div>
36 <div class="pf-v6-c-code-block__actions-item">
37 <button
38 class="pf-v6-c-button pf-m-plain"
39 type="button"
40 aria-label="Run basic example code in Web Terminal"
41 >
42 <span class="pf-v6-c-button__icon">
43 <svg
44 class="pf-v6-svg"
45 fill="currentColor"
46 viewBox="0 0 448 512"
47 aria-hidden="true"
48 role="img"
49 width="1em"
50 height="1em"
51 >
52 <path
53 d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"
54 />
55 </svg>
56 </span>
57 </button>
58 </div>
59 </div>
60 </div>
61 <div class="pf-v6-c-code-block__content">
62 <pre class="pf-v6-c-code-block__pre"><code class="pf-v6-c-code-block__code">apiVersion: helm.openshift.io/v1beta1/
63 kind: HelmChartRepository
64 metadata:
65 name: azure-sample-repo
66 spec:
67 connectionConfig:
68 url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs</code>
69 </pre>
70 </div>
71 </div>
72
73 ```
74
75 ### Expandable
76
77 ```html
78 <div class="pf-v6-c-code-block">
79 <div class="pf-v6-c-code-block__header">
80 <div class="pf-v6-c-code-block__actions">
81 <div class="pf-v6-c-code-block__actions-item">
82 <button
83 class="pf-v6-c-button pf-m-plain"
84 type="button"
85 aria-label="Copy to clipboard expandable example code content"
86 >
87 <span class="pf-v6-c-button__icon">
88 <svg
89 class="pf-v6-svg"
90 fill="currentColor"
91 viewBox="0 0 448 512"
92 aria-hidden="true"
93 role="img"
94 width="1em"
95 height="1em"
96 >
97 <path
98 d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
99 />
100 </svg>
101 </span>
102 </button>
103 </div>
104 <div class="pf-v6-c-code-block__actions-item">
105 <button
106 class="pf-v6-c-button pf-m-plain"
107 type="button"
108 aria-label="Run expandable example code in Web Terminal"
109 >
110 <span class="pf-v6-c-button__icon">
111 <svg
112 class="pf-v6-svg"
113 fill="currentColor"
114 viewBox="0 0 448 512"
115 aria-hidden="true"
116 role="img"
117 width="1em"
118 height="1em"
119 >
120 <path
121 d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"
122 />
123 </svg>
124 </span>
125 </button>
126 </div>
127 </div>
128 </div>
129 <div class="pf-v6-c-code-block__content">
130 <pre class="pf-v6-c-code-block__pre"><code class="pf-v6-c-code-block__code">apiVersion: helm.openshift.io/v1beta1/
131 kind: HelmChartRepository
132 metadata:
133 name: azure-sample-repo<div
134 class="pf-v6-c-expandable-section pf-m-detached"
135 ><div
136 class="pf-v6-c-expandable-section__content"
137 hidden
138 id="code-block-expandable-content"
139 role="region"
140 aria-labelledby="code-block-expandable-toggle"
141 >
142 spec:
143 connectionConfig:
144 url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs</div>
145 </div>
146 </code>
147 </pre>
148 <div class="pf-v6-c-expandable-section pf-m-detached">
149 <div class="pf-v6-c-expandable-section__toggle">
150 <button
151 class="pf-v6-c-button pf-m-link"
152 id="code-block-expandable-toggle"
153 type="button"
154 aria-expanded="false"
155 aria-controls="code-block-expandable-content"
156 >
157 <span class="pf-v6-c-button__icon pf-m-start">
158 <span
159 class="pf-v6-c-expandable-section__toggle-icon pf-m-expand-top"
160 >
161 <svg
162 class="pf-v6-svg"
163 fill="currentColor"
164 viewBox="0 0 20 20"
165 aria-hidden="true"
166 role="img"
167 width="1em"
168 height="1em"
169 >
170 <path
171 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
172 />
173 </svg>
174 </span>
175 </span>
176 <span class="pf-v6-c-button__text">Show more</span>
177 </button>
178 </div>
179 </div>
180 </div>
181 </div>
182
183 ```
184
185 ### Expandable expanded
186
187 ```html
188 <div class="pf-v6-c-code-block">
189 <div class="pf-v6-c-code-block__header">
190 <div class="pf-v6-c-code-block__actions">
191 <div class="pf-v6-c-code-block__actions-item">
192 <button
193 class="pf-v6-c-button pf-m-plain"
194 type="button"
195 aria-label="Copy to clipboard expandable expanded example code content"
196 >
197 <span class="pf-v6-c-button__icon">
198 <svg
199 class="pf-v6-svg"
200 fill="currentColor"
201 viewBox="0 0 448 512"
202 aria-hidden="true"
203 role="img"
204 width="1em"
205 height="1em"
206 >
207 <path
208 d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
209 />
210 </svg>
211 </span>
212 </button>
213 </div>
214 <div class="pf-v6-c-code-block__actions-item">
215 <button
216 class="pf-v6-c-button pf-m-plain"
217 type="button"
218 aria-label="Run expandable expanded example code in Web Terminal"
219 >
220 <span class="pf-v6-c-button__icon">
221 <svg
222 class="pf-v6-svg"
223 fill="currentColor"
224 viewBox="0 0 448 512"
225 aria-hidden="true"
226 role="img"
227 width="1em"
228 height="1em"
229 >
230 <path
231 d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"
232 />
233 </svg>
234 </span>
235 </button>
236 </div>
237 </div>
238 </div>
239 <div class="pf-v6-c-code-block__content">
240 <pre class="pf-v6-c-code-block__pre"><code class="pf-v6-c-code-block__code">apiVersion: helm.openshift.io/v1beta1/
241 kind: HelmChartRepository
242 metadata:
243 name: azure-sample-repo<div
244 class="pf-v6-c-expandable-section pf-m-expanded pf-m-detached"
245 ><div
246 class="pf-v6-c-expandable-section__content"
247 id="code-block-expandable-expanded-content"
248 role="region"
249 aria-labelledby="code-block-expandable-expanded-toggle"
250 >
251 spec:
252 connectionConfig:
253 url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs</div>
254 </div>
255 </code>
256 </pre>
257 <div class="pf-v6-c-expandable-section pf-m-expanded pf-m-detached">
258 <div class="pf-v6-c-expandable-section__toggle">
259 <button
260 class="pf-v6-c-button pf-m-link"
261 id="code-block-expandable-expanded-toggle"
262 type="button"
263 aria-expanded="true"
264 aria-controls="code-block-expandable-expanded-content"
265 >
266 <span class="pf-v6-c-button__icon pf-m-start">
267 <span
268 class="pf-v6-c-expandable-section__toggle-icon pf-m-expand-top"
269 >
270 <svg
271 class="pf-v6-svg"
272 fill="currentColor"
273 viewBox="0 0 20 20"
274 aria-hidden="true"
275 role="img"
276 width="1em"
277 height="1em"
278 >
279 <path
280 d="M18.71 5.29a.996.996 0 0 0-1.41 0l-7.29 7.29-7.3-7.29a.987.987 0 0 0-1.41-.02.987.987 0 0 0-.02 1.41l.02.02 7.65 7.65c.29.29.68.44 1.06.44s.77-.15 1.06-.44l7.65-7.65a.996.996 0 0 0 0-1.41Z"
281 />
282 </svg>
283 </span>
284 </span>
285 <span class="pf-v6-c-button__text">Show less</span>
286 </button>
287 </div>
288 </div>
289 </div>
290 </div>
291
292 ```
293
294 ## Documentation
295
296 ### Usage
297
298 | Class | Applied to | Outcome |
299 | -- | -- | -- |
300 | `.pf-v6-c-code-block` | `<div>` | Initiates the code block component. **Required** |
301 | `.pf-v6-c-code-block__header` | `<div>` | Initiates the code block header. |
302 | `.pf-v6-c-code-block__actions` | `<div>` | Initiates the code block actions. |
303 | `.pf-v6-c-code-block__actions-item` | `<div>` | Initiates a code block action item. |
304 | `.pf-v6-c-code-block__content` | `<div>` | Initiates the code block content. **Required** |
305 | `.pf-v6-c-code-block__pre` | `<pre>` | Initiates the code block `<pre>` element. **Required** |
306 | `.pf-v6-c-code-block__code` | `<code>` | Initiates the code block `<code>` element. **Required** |