Skip to content

Commit 0f8a51f

Browse files
committed
add(types): Add and improve JSDOC types to props
1 parent 9ac0c6a commit 0f8a51f

35 files changed

+177
-95
lines changed

components/custom/Badge/Badge.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<script>
2+
/** @type {string} the background color of the badge. Defaults to "gray" */
23
export let color = 'gray'
4+
/** @type {string} the border radius of the badge. Defaults to "50%" */
35
export let borderRadius = '50%'
6+
/** @type {string} the padding of the badge. Defaults to ".2em" */
47
export let padding = '.2em'
8+
/** @type {boolean} if the badge is bordered or not */
59
export let bordered = false
610
711
let transparentColor = ''

components/custom/DateInput/DateInput.svelte

Lines changed: 11 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,25 @@
11
<script>
2-
/**
3-
* @component DateInput
4-
* @description Date input with custom styling
5-
*/
6-
7-
/**
8-
* @prop {string}
9-
* @description sets color of input text
10-
*/
2+
/** @type {string} sets color of input text */
113
export let color = 'black'
12-
13-
/**
14-
* @prop {string}
15-
* @description sets color of input border
16-
*/
4+
/** @type {string} sets color of input border */
175
export let borderColor = 'black'
18-
19-
/**
20-
* @prop {string}
21-
* @description sets color of input text after blur when required and empty
22-
*/
6+
/** @type {string} sets color of input text after blur when required and empty */
237
export let errorColor = 'red'
24-
25-
/**
26-
* @prop {string}
27-
* @description sets padding of input
28-
*/
8+
/** @type {string} sets padding of input */
299
export let padding = '12px'
30-
31-
/**
32-
* @prop {string}
33-
* @description sets width of input
34-
*/
10+
/** @type {string} sets width of input */
3511
export let width = '220px'
36-
37-
/**
38-
* @prop {string}
39-
* @description sets font size input text
40-
*/
12+
/** @type {string} sets font size input text */
4113
export let fontSize = '14px'
42-
43-
/**
44-
* @prop {string}
45-
* @description sets name of input
46-
*/
14+
/** @type {string} sets name of input */
4715
export let name = ''
48-
49-
/**
50-
* @prop {string} date in locale with no time data
51-
* @description sets initial date of input
52-
*/
16+
/** @type {string} sets initial date of input in locale with no time data */
5317
export let value = ''
54-
55-
/**
56-
* @prop {boolean}
57-
* @description sets whether input is disabled
58-
*/
18+
/** @type {boolean} sets whether input is disabled */
5919
export let disabled = false
60-
61-
/**
62-
* @prop {boolean}
63-
* @description sets whether input is focused on load
64-
*/
20+
/** @type {boolean} sets whether input is focused on load */
6521
export let autofocus = false
66-
67-
/**
68-
* @prop {boolean}
69-
* @description sets whether input is required and has error color when empty after blur
70-
*/
22+
/** @type {boolean} sets whether input is required and has error color when empty after blur */
7123
export let required = false
7224
7325
const onBlur = (e) => {

components/custom/FileDropArea/FileDropArea.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
import { isAboveMobile } from '../../mdc'
33
import { createEventDispatcher } from 'svelte'
44
5+
/** @type {boolean} if the button uses raised styling or not */
56
export let raised = false
7+
/** @type {boolean} if the button uses outlined styling or not */
68
export let outlined = false
9+
/** @type {boolean} if the button is disabled or not */
710
export let uploading = false
11+
/** @type {string} the mime type of the file. Defaults to 'application/pdf,image/*' */
812
export let mimeType = 'application/pdf,image/*'
913
1014
let fileInput = {}

components/custom/Form/Form.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import { onMount } from 'svelte'
33
import { generateRandomID } from '../../../random'
44
5+
/** @type {string} the id of the form which is generated by defaults */
56
export let id = generateRandomID('form-')
7+
/** @type {boolean} if the form should save its values to local storage */
68
export let saveToLocalStorage = false
79
810
let form = {}

components/custom/SearchableSelect/SearchableSelect.svelte

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@
22
import { generateRandomID } from '../../../random'
33
import { createEventDispatcher } from 'svelte'
44
5+
/** @type {object} the options to choose from. The keys are displayed in the dropdown and the value is dispatched with the change event */
56
export let options = {}
7+
/** @type {string} the currently selected option value */
68
export let choice = ''
9+
/** @type {string} the placeholder text which is also used as a floating label */
710
export let placeholder = ''
11+
/** @type {string} the padding around the input label */
812
export let padding = '12px'
13+
/** @type {string} the width of the input */
914
export let width = '232px'
15+
/** @type {number} the maximum length of the input */
1016
export let maxlength = 255
17+
/** @type {boolean} if the input is disabled or not */
1118
export let disabled = false
19+
/** @type {boolean} if the input is required or not */
1220
export let required = false
1321
1422
let element = {}
@@ -54,7 +62,10 @@ const onChange = (e) => {
5462
text-overflow: ellipsis;
5563
left: var(--field-padding);
5664
width: calc(100% - (var(--field-padding) * 2));
57-
transition: top 0.3s ease, color 0.3s ease, font-size 0.3s ease;
65+
transition:
66+
top 0.3s ease,
67+
color 0.3s ease,
68+
font-size 0.3s ease;
5869
}
5970
6071
.custom-field input:not(:placeholder-shown) + .placeholder,

components/custom/StaticChip/StaticChip.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
/** @type {string} the background color of the chip */
23
export let bgColor = '#e5e5e5'
34
</script>
45

components/mdc/Button/Button.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
import { MDCRipple } from '@material/ripple'
44
import { onMount } from 'svelte'
55
6+
/** @type {boolean} if the button is disabled or not */
67
export let disabled = false
8+
/** @type {boolean} if the button used outlined styling or not */
79
export let outlined = false
10+
/** @type {boolean} if the button uses raised styling or not */
811
export let raised = false
12+
/** @type {string} the prepend icon */
913
export let prependIcon = undefined
14+
/** @type {string} the append icon */
1015
export let appendIcon = undefined
16+
/** @type {string} the URL of the button. If used the element will be an anchor. */
1117
export let url = undefined
18+
/** @type {string} the `target` attribute of the anchor element if `url` is used */
1219
export let target = ''
1320
1421
let element = {}

components/mdc/Card/Card.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<!-- https://github.com/material-components/material-components-web/tree/master/packages/mdc-card -->
22
<script>
3+
/** @type {string} the secondary text */
34
export let secondary = ''
5+
/** @type {boolean} if the card is outlined or not */
46
export let outlined = false
7+
/** @type {string} the background color. Defaults to "white" */
58
export let color = 'white'
9+
/** @type {boolean} if the card is clickable or not */
610
export let isClickable = false
11+
/** @type {boolean} if the card should have padding or not */
712
export let noPadding = false
813
914
$: tabindex = isClickable ? 0 : undefined

components/mdc/Checkbox/Checkbox.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import { createEventDispatcher, onMount } from 'svelte'
77
88
const dispatch = createEventDispatcher()
99
10+
/** @type {string} the label text*/
1011
export let label = ''
12+
/** @type {boolean} if the checkbox is checked or not */
1113
export let checked = false
14+
/** @type {boolean} if the checkbox is disabled or not */
1215
export let disabled = false
16+
/** @type {boolean} if the label should be uppercase or not */
1317
export let uppercase = false
1418
1519
let checkboxElement = {}

components/mdc/CustomCard/CustomCard.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
import Button from '../Button'
33
import Card from '../Card'
44
5+
/** @type {string} the image source */
56
export let src = ''
7+
/** @type {string} the image alt text, default to "image is missing" */
68
export let alt = 'image is missing'
9+
/** @type {string} the card title, default to "Title" */
710
export let title = 'Title'
11+
/** @type {string} the icon name */
812
export let icon = ''
13+
/** @type {boolean} if the card is disabled or not */
914
export let disabled = false
15+
/** @type {{label, url}[]} */
1016
export let buttons
17+
/** @type {string} the footer text */
1118
export let footerText = ''
1219
</script>
1320

0 commit comments

Comments
 (0)