Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 271a628

Browse files
doc: add code example
1 parent 7646459 commit 271a628

File tree

2 files changed

+51
-15
lines changed

2 files changed

+51
-15
lines changed

doc/slides/slides.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,31 @@ The "Code" slide is a the slide to use if you would like to showcase code during
217217

218218
The "Code" slide's Web Component could be integrated using the tag `<deckgo-slide-code/>`.
219219

220+
You could provide a file URI to the code you want to display or provide it with a slotted element.
221+
222+
#### Usage with file URI
223+
220224
```
221225
<deckgo-slide-code src-file="https://domain.com/path-to-my-code.extension">
222226
<h1 slot="title">My code</h1>
223227
</deckgo-slide-code>
224228
```
225229

230+
#### Usage with slotted element
231+
232+
```
233+
<deckgo-slide-code language="java">
234+
<h1 slot="title">Manual code</h1>
235+
<code slot="code">
236+
interface DeckDeckGoDemo {
237+
boolean helloWorld();
238+
}
239+
</deckgo-slide-code>
240+
```
241+
226242
#### Slots
227243

228-
The slot `title` is optional.
244+
The slots `title` and `code` are optional.
229245

230246
### Attributes
231247

@@ -239,14 +255,36 @@ The attribute `src-file` is for this component mandatory. Other attributes are o
239255
| hide-anchor | boolean | true | Set this attribute to `false` in case you would like to actually display the anchor value too |
240256
| language | string | javascript | Define the language to be used for the syntax highlighting. The list of [supported languages](https://prismjs.com/#languages-list) is defined by [Prism.js](https://prismjs.com/#languages-list) |
241257

242-
#### Example
258+
#### Example with file URI
243259

244260
```
245261
<deckgo-slide-code hide-anchor="fals" src-file="https://raw.githubusercontent.com/fluster/deckdeckgo/master/src/components/slides/deckdeckgo-slide-code/deckdeckgo-slide-code.tsx">
246262
<h1 slot="title">Code</h1>
247263
</deckgo-slide-code>
248264
```
249265

266+
#### Example with slotted element
267+
268+
```
269+
<deckgo-slide-code language="java">
270+
<h1 slot="title">Manual code</h1>
271+
<code slot="code">interface NumericTest {
272+
boolean computeTest(int n);
273+
}
274+
275+
public static void main(String args[]) {
276+
NumericTest isEven = (n) -> (n % 2) == 0;
277+
NumericTest isNegative = (n) -> (n < 0);
278+
279+
// Output: false
280+
System.out.println(isEven.computeTest(5));
281+
282+
// Output: true
283+
System.out.println(isNegative.computeTest(-5));
284+
}</code>
285+
</deckgo-slide-code>
286+
```
287+
250288
### Theming
251289

252290
The following theming options will affect this component if set on its host or parent.

src/index.html

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,20 @@ <h1 slot="title">Code</h1>
105105

106106
<deckgo-slide-code language="java">
107107
<h1 slot="title">Manual code</h1>
108-
<div slot="code">
109-
interface NumericTest {
110-
boolean computeTest(int n);
111-
}
108+
<code slot="code">interface NumericTest {
109+
boolean computeTest(int n);
110+
}
112111

113-
public static void main(String args[]) {
114-
NumericTest isEven = (n) -> (n % 2) == 0;
115-
NumericTest isNegative = (n) -> (n < 0);
112+
public static void main(String args[]) {
113+
NumericTest isEven = (n) -> (n % 2) == 0;
114+
NumericTest isNegative = (n) -> (n < 0);
116115

117-
// Output: false
118-
System.out.println(isEven.computeTest(5));
116+
// Output: false
117+
System.out.println(isEven.computeTest(5));
119118

120-
// Output: true
121-
System.out.println(isNegative.computeTest(-5));
122-
}
123-
</div>
119+
// Output: true
120+
System.out.println(isNegative.computeTest(-5));
121+
}</code>
124122
</deckgo-slide-code>
125123

126124
</deckgo-deck>

0 commit comments

Comments
 (0)