@samuelgomez/astro 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +54 -0
  2. package/package.json +42 -0
  3. package/src/components/Accordion/index.astro +31 -0
  4. package/src/components/Alert/AlertDanger.astro +12 -0
  5. package/src/components/Alert/AlertInfo.astro +12 -0
  6. package/src/components/Alert/AlertSuccess.astro +12 -0
  7. package/src/components/Alert/AlertWarning.astro +12 -0
  8. package/src/components/Alert/index.astro +10 -0
  9. package/src/components/Badge/BadgeDanger.astro +15 -0
  10. package/src/components/Badge/BadgeInfo.astro +15 -0
  11. package/src/components/Badge/BadgeSuccess.astro +15 -0
  12. package/src/components/Badge/BadgeWarning.astro +15 -0
  13. package/src/components/Badge/index.astro +9 -0
  14. package/src/components/Box/index.astro +45 -0
  15. package/src/components/BoxPost/index.astro +66 -0
  16. package/src/components/Button/index.astro +35 -0
  17. package/src/components/Caniuse/index.astro +24 -0
  18. package/src/components/Codepen/index.astro +25 -0
  19. package/src/components/DebugGrid/index.astro +100 -0
  20. package/src/components/Demo/Demoui.astro +13 -0
  21. package/src/components/Demo/index.astro +105 -0
  22. package/src/components/Dialog/index.astro +74 -0
  23. package/src/components/FormattedDate/index.astro +17 -0
  24. package/src/components/GithubContributions/index.astro +88 -0
  25. package/src/components/Home/CardsBlog.astro +41 -0
  26. package/src/components/Home/CardsCodepen.astro +53 -0
  27. package/src/components/Home/CardsGithub.astro +44 -0
  28. package/src/components/Img/index.astro +28 -0
  29. package/src/components/Link/index.astro +33 -0
  30. package/src/components/Nav/NavToggle.astro +40 -0
  31. package/src/components/Nav/index.astro +71 -0
  32. package/src/components/Pagination/PaginationItem.astro +51 -0
  33. package/src/components/Pagination/index.astro +39 -0
  34. package/src/components/ScrollWatcher/index.astro +11 -0
  35. package/src/components/Social/index.astro +22 -0
  36. package/src/components/Support/index.astro +24 -0
  37. package/src/components/Svg/index.astro +30 -0
  38. package/src/components/SwitchTheme.astro +45 -0
  39. package/src/components/Table/Table.astro +15 -0
  40. package/src/components/Table/TableBody.astro +21 -0
  41. package/src/components/Table/TableHeader.astro +19 -0
  42. package/src/components/Table/index.astro +21 -0
  43. package/src/components/TableOfContent/index.astro +117 -0
  44. package/src/components/Tabs/TabList.astro +23 -0
  45. package/src/components/Tabs/TabListItem.astro +22 -0
  46. package/src/components/Tabs/TabPanel.astro +19 -0
  47. package/src/components/Tabs/TabsContainer.astro +174 -0
  48. package/src/components/Tabs/index.astro +46 -0
  49. package/src/components/Title/h1.astro +12 -0
  50. package/src/components/Title/h2.astro +12 -0
  51. package/src/components/Title/h3.astro +12 -0
  52. package/src/components/Title/h4.astro +12 -0
  53. package/src/components/Title/h5.astro +12 -0
  54. package/src/components/Title/h6.astro +12 -0
  55. package/src/components/Title/heading.astro +8 -0
  56. package/src/components/Title/index.astro +39 -0
  57. package/src/components/WrapperToHtml/index.astro +8 -0
  58. package/src/components/form/Field/index.astro +43 -0
  59. package/src/components/form/Fieldset/index.astro +14 -0
  60. package/src/components/form/Form/FieldDate.astro +32 -0
  61. package/src/components/form/Form/FieldEmail.astro +32 -0
  62. package/src/components/form/Form/FieldNumber.astro +35 -0
  63. package/src/components/form/Form/FieldPassword.astro +32 -0
  64. package/src/components/form/Form/FieldRadio.astro +32 -0
  65. package/src/components/form/Form/FieldSelect.astro +26 -0
  66. package/src/components/form/Form/FieldText.astro +35 -0
  67. package/src/components/form/Form/FieldTextarea.astro +25 -0
  68. package/src/components/form/Form/index.astro +5 -0
  69. package/src/components/form/Input/index.astro +27 -0
  70. package/src/components/form/InputRadio/index.astro +30 -0
  71. package/src/components/form/MoreInfo/index.astro +14 -0
  72. package/src/components/form/Select/index.astro +25 -0
  73. package/src/components/form/Status/index.astro +34 -0
  74. package/src/components/form/Textarea/index.astro +26 -0
  75. package/src/components/helpers/WrapperOrNot/index.astro +23 -0
  76. package/src/components/layout/Footer.astro +3 -0
  77. package/src/components/layout/Head.astro +154 -0
  78. package/src/components/layout/Header.astro +28 -0
  79. package/src/components/old/Grid.astro +18 -0
  80. package/src/components/old/Section.astro +19 -0
  81. package/src/components/old/SwitchTheme.astro +66 -0
  82. package/src/components/old/index-webco.astro +55 -0
  83. package/src/components/old/send.astro +28 -0
  84. package/src/helpers/dom.ts +19 -0
  85. package/src/helpers/isEmptyOrNull.test.ts +58 -0
  86. package/src/helpers/isEmptyOrNull.ts +6 -0
  87. package/src/helpers/setSlug.test.ts +20 -0
  88. package/src/helpers/setSlug.ts +7 -0
  89. package/src/helpers/setTocTitle.ts +2 -0
  90. package/src/helpers/setVariants.test.ts +26 -0
  91. package/src/helpers/setVariants.ts +18 -0
  92. package/src/icons/Add.astro +18 -0
  93. package/src/icons/Anchor.astro +22 -0
  94. package/src/icons/Arrow.astro +11 -0
  95. package/src/icons/AstroLogo.astro +35 -0
  96. package/src/icons/Check.astro +11 -0
  97. package/src/icons/ChevronDown.astro +11 -0
  98. package/src/icons/ChevronLeft.astro +11 -0
  99. package/src/icons/ChevronRight.astro +11 -0
  100. package/src/icons/Codepen.astro +36 -0
  101. package/src/icons/Cross.astro +11 -0
  102. package/src/icons/ExternalLink.astro +19 -0
  103. package/src/icons/Github.astro +36 -0
  104. package/src/icons/Github2.astro +11 -0
  105. package/src/icons/Grid.astro +19 -0
  106. package/src/icons/Info.astro +11 -0
  107. package/src/icons/Instagram.astro +11 -0
  108. package/src/icons/Linkedin.astro +11 -0
  109. package/src/icons/LogoSG.astro +66 -0
  110. package/src/icons/MoonSun.astro +17 -0
  111. package/src/icons/Send.astro +11 -0
  112. package/src/icons/Slash.astro +14 -0
  113. package/src/icons/Trash.astro +19 -0
  114. package/src/icons/Twitter.astro +14 -0
  115. package/src/types/Permutations.d.ts +3 -0
@@ -0,0 +1,12 @@
1
+ ---
2
+ import Title from './index.astro';
3
+
4
+ type Props = {
5
+ label: string;
6
+ noLink?: boolean;
7
+ };
8
+
9
+ const props = Astro.props;
10
+ ---
11
+
12
+ <Title level={6} {...props}><slot /></Title>
@@ -0,0 +1,8 @@
1
+ ---
2
+ export { default as h1 } from './h1.astro';
3
+ export { default as h2 } from './h2.astro';
4
+ export { default as h3 } from './h3.astro';
5
+ export { default as h4 } from './h4.astro';
6
+ export { default as h5 } from './h5.astro';
7
+ export { default as h6 } from './h6.astro';
8
+ ---
@@ -0,0 +1,39 @@
1
+ ---
2
+ import type { HTMLTag } from 'astro/types';
3
+ import Link from '@samuelgomez/astro/components/Link/index.astro';
4
+ import Anchor from '@samuelgomez/astro/icons/Anchor.astro';
5
+ import { setSlug } from '@samuelgomez/astro/helpers/setSlug';
6
+
7
+ export type titleLevel = 1 | 2 | 3 | 4 | 5 | 6;
8
+
9
+ type Props = {
10
+ label?: string;
11
+ level?: titleLevel;
12
+ noLink?: boolean;
13
+ id?: string;
14
+ };
15
+
16
+ const { label, level = 1, noLink, id, ...props } = Astro.props;
17
+
18
+ const htmlLabel = await Astro.slots.render('default');
19
+
20
+ const idHeading = label ? setSlug(label) : id?.replace('--', '-');
21
+
22
+ const title = label || htmlLabel.toString();
23
+
24
+ const Heading = `h${level}` as HTMLTag;
25
+ ---
26
+
27
+ <Heading {...props} id={idHeading}>
28
+ {
29
+ !noLink && idHeading && (
30
+ <Link href={`#${idHeading}`}>
31
+ <Anchor slot="after-link" title={title} />
32
+ </Link>
33
+ )
34
+ }
35
+ <slot name="before-title" />
36
+ {label}
37
+ <slot />
38
+ <slot name="after-title" />
39
+ </Heading>
@@ -0,0 +1,8 @@
1
+ ---
2
+ const html = await Astro.slots.render('default');
3
+ import { Code } from 'astro/components';
4
+ ---
5
+
6
+ <Fragment set:html={html} />
7
+
8
+ <Code code={html} lang="html" />
@@ -0,0 +1,43 @@
1
+ ---
2
+ import MoreInfo from '@samuelgomez/astro/components/form/MoreInfo/index.astro';
3
+ import Status from '@samuelgomez/astro/components/form/Status/index.astro';
4
+
5
+ type Props = {
6
+ id?: string;
7
+ name: string;
8
+ label: string;
9
+ moreInfo: string;
10
+ help: string;
11
+ errorMessage?: string;
12
+ title?: string;
13
+ required?: boolean;
14
+ };
15
+
16
+ const {
17
+ name,
18
+ id = name,
19
+ label,
20
+ moreInfo,
21
+ help,
22
+ errorMessage,
23
+ title,
24
+ required = true,
25
+ } = Astro.props;
26
+
27
+ const html = await Astro.slots.render('default', [name]);
28
+ ---
29
+
30
+ <div class="field">
31
+ <label id={`label-${name}`} for={id}>{label}</label>
32
+ {moreInfo && <MoreInfo moreInfo={moreInfo} />}
33
+ <div class="input-container">
34
+ <Fragment set:html={html} />
35
+ </div>
36
+ <Status
37
+ required={required}
38
+ id={id || name}
39
+ help={help}
40
+ errorMessage={errorMessage}
41
+ title={title}
42
+ />
43
+ </div>
@@ -0,0 +1,14 @@
1
+ ---
2
+ type Props = {
3
+ legend: string;
4
+ };
5
+
6
+ const { legend } = Astro.props;
7
+ ---
8
+
9
+ <div class="fieldset-grid box">
10
+ <fieldset>
11
+ <legend>{legend}</legend>
12
+ <slot />
13
+ </fieldset>
14
+ </div>
@@ -0,0 +1,32 @@
1
+ ---
2
+ import Field from '@samuelgomez/astro/components/form/Field/index.astro';
3
+ import Input from '@samuelgomez/astro/components/form/Input/index.astro';
4
+
5
+ const {
6
+ name = 'date',
7
+ label = 'Votre date',
8
+ moreInfo = "Plus d'infos",
9
+ help = 'Aide',
10
+ autocomplete = null,
11
+ required = true,
12
+ errorMessage = undefined,
13
+ ...rest
14
+ } = Astro.props;
15
+ ---
16
+
17
+ <Field
18
+ name={name}
19
+ label={label}
20
+ moreInfo={moreInfo}
21
+ help={help}
22
+ required={required}
23
+ errorMessage={errorMessage}
24
+ >
25
+ <Input
26
+ name={name}
27
+ autocomplete={autocomplete}
28
+ type="date"
29
+ required={required}
30
+ {...rest}
31
+ />
32
+ </Field>
@@ -0,0 +1,32 @@
1
+ ---
2
+ import Field from '@samuelgomez/astro/components/form/Field/index.astro';
3
+ import Input from '@samuelgomez/astro/components/form/Input/index.astro';
4
+
5
+ const {
6
+ name = 'email',
7
+ label = 'Votre email',
8
+ moreInfo = "Plus d'infos",
9
+ help = 'Aide',
10
+ autocomplete = 'email',
11
+ required = true,
12
+ errorMessage = undefined,
13
+ ...rest
14
+ } = Astro.props;
15
+ ---
16
+
17
+ <Field
18
+ name={name}
19
+ label={label}
20
+ moreInfo={moreInfo}
21
+ help={help}
22
+ required={required}
23
+ errorMessage={errorMessage}
24
+ >
25
+ <Input
26
+ name={name}
27
+ autocomplete={autocomplete}
28
+ type="email"
29
+ required={required}
30
+ {...rest}
31
+ />
32
+ </Field>
@@ -0,0 +1,35 @@
1
+ ---
2
+ import Field from '@samuelgomez/astro/components/form/Field/index.astro';
3
+ import Input from '@samuelgomez/astro/components/form/Input/index.astro';
4
+
5
+ const {
6
+ name = 'text',
7
+ label = 'Votre text',
8
+ moreInfo = "Plus d'infos",
9
+ help = 'Aide',
10
+ autocomplete = null,
11
+ errorMessage = undefined,
12
+ required = true,
13
+ title = undefined,
14
+ ...rest
15
+ } = Astro.props;
16
+ ---
17
+
18
+ <Field
19
+ name={name}
20
+ label={label}
21
+ moreInfo={moreInfo}
22
+ help={help}
23
+ errorMessage={errorMessage}
24
+ required={required}
25
+ title={title}
26
+ >
27
+ <Input
28
+ name={name}
29
+ autocomplete={autocomplete}
30
+ type="number"
31
+ required={required}
32
+ title={title}
33
+ {...rest}
34
+ />
35
+ </Field>
@@ -0,0 +1,32 @@
1
+ ---
2
+ import Field from '@samuelgomez/astro/components/form/Field/index.astro';
3
+ import Input from '@samuelgomez/astro/components/form/Input/index.astro';
4
+
5
+ const {
6
+ name = 'password',
7
+ label = 'Votre mot de passe',
8
+ moreInfo = "Plus d'infos",
9
+ help = 'Aide',
10
+ autocomplete = 'off',
11
+ required = true,
12
+ errorMessage = undefined,
13
+ ...rest
14
+ } = Astro.props;
15
+ ---
16
+
17
+ <Field
18
+ name={name}
19
+ label={label}
20
+ moreInfo={moreInfo}
21
+ help={help}
22
+ required={required}
23
+ errorMessage={errorMessage}
24
+ >
25
+ <Input
26
+ name={name}
27
+ autocomplete={autocomplete}
28
+ type="password"
29
+ required={required}
30
+ {...rest}
31
+ />
32
+ </Field>
@@ -0,0 +1,32 @@
1
+ ---
2
+ import Field from '@samuelgomez/astro/components/form/Field/index.astro';
3
+ import Radio from '@samuelgomez/astro/components/form/InputRadio/index.astro';
4
+
5
+ const {
6
+ name = 'selection',
7
+ label = 'Votre sélection',
8
+ moreInfo = "Plus d'infos",
9
+ help = 'Aide',
10
+ options = [],
11
+ errorMessage = undefined,
12
+ required = true,
13
+ ...rest
14
+ } = Astro.props;
15
+ ---
16
+
17
+ <Field
18
+ name={name}
19
+ label={label}
20
+ moreInfo={moreInfo}
21
+ help={help}
22
+ errorMessage={errorMessage}
23
+ required={required}
24
+ >
25
+ <Radio
26
+ legend={label}
27
+ name={name}
28
+ options={options}
29
+ required={required}
30
+ {...rest}
31
+ />
32
+ </Field>
@@ -0,0 +1,26 @@
1
+ ---
2
+ import Field from '@samuelgomez/astro/components/form/Field/index.astro';
3
+ import Select from '@samuelgomez/astro/components/form/Select/index.astro';
4
+
5
+ const {
6
+ name = 'selection',
7
+ label = 'Votre sélection',
8
+ moreInfo = "Plus d'infos",
9
+ help = 'Aide',
10
+ options = [],
11
+ errorMessage = undefined,
12
+ required = true,
13
+ ...rest
14
+ } = Astro.props;
15
+ ---
16
+
17
+ <Field
18
+ name={name}
19
+ label={label}
20
+ moreInfo={moreInfo}
21
+ help={help}
22
+ required={required}
23
+ errorMessage={errorMessage}
24
+ >
25
+ <Select name={name} options={options} required={required} {...rest} />
26
+ </Field>
@@ -0,0 +1,35 @@
1
+ ---
2
+ import Field from '@samuelgomez/astro/components/form/Field/index.astro';
3
+ import Input from '@samuelgomez/astro/components/form/Input/index.astro';
4
+
5
+ const {
6
+ name = 'text',
7
+ label = 'Votre text',
8
+ moreInfo = "Plus d'infos",
9
+ help = 'Aide',
10
+ autocomplete = null,
11
+ errorMessage = undefined,
12
+ required = true,
13
+ title = undefined,
14
+ ...rest
15
+ } = Astro.props;
16
+ ---
17
+
18
+ <Field
19
+ name={name}
20
+ label={label}
21
+ moreInfo={moreInfo}
22
+ help={help}
23
+ errorMessage={errorMessage}
24
+ required={required}
25
+ title={title}
26
+ >
27
+ <Input
28
+ name={name}
29
+ autocomplete={autocomplete}
30
+ type="text"
31
+ required={required}
32
+ title={title}
33
+ {...rest}
34
+ />
35
+ </Field>
@@ -0,0 +1,25 @@
1
+ ---
2
+ import Field from '@samuelgomez/astro/components/form/Field/index.astro';
3
+ import Textarea from '@samuelgomez/astro/components/form/Textarea/index.astro';
4
+
5
+ const {
6
+ name = 'text',
7
+ label = 'Votre text',
8
+ moreInfo = "Plus d'infos",
9
+ help = 'Aide',
10
+ errorMessage = undefined,
11
+ required = true,
12
+ ...rest
13
+ } = Astro.props;
14
+ ---
15
+
16
+ <Field
17
+ name={name}
18
+ label={label}
19
+ moreInfo={moreInfo}
20
+ help={help}
21
+ required={required}
22
+ errorMessage={errorMessage}
23
+ >
24
+ <Textarea name={name} required={required} {...rest} />
25
+ </Field>
@@ -0,0 +1,5 @@
1
+ ---
2
+ const props = Astro.props;
3
+ ---
4
+
5
+ <form {...props}><slot /></form>
@@ -0,0 +1,27 @@
1
+ ---
2
+ type Props = astroHTML.JSX.InputHTMLAttributes & {
3
+ ariaDescribedby?: string;
4
+ };
5
+
6
+ const {
7
+ name,
8
+ autocomplete,
9
+ type = 'text',
10
+ required = true,
11
+ id = name,
12
+ value,
13
+ ariaDescribedby = `help-${id}`,
14
+ ...inputProps
15
+ } = Astro.props;
16
+ ---
17
+
18
+ <input
19
+ type={type}
20
+ name={name}
21
+ required={required}
22
+ id={id}
23
+ value={value}
24
+ autocomplete={autocomplete}
25
+ aria-describedby={ariaDescribedby}
26
+ {...inputProps}
27
+ />
@@ -0,0 +1,30 @@
1
+ ---
2
+ type Props = Partial<HTMLInputElement> & {
3
+ ariaDescribedby?: string;
4
+ options: {
5
+ label: string;
6
+ value: string;
7
+ }[];
8
+ legend: string;
9
+ };
10
+
11
+ const { name, required = true, options, legend } = Astro.props;
12
+ ---
13
+
14
+ <fieldset>
15
+ <legend class="sr-only">{legend}</legend>
16
+ {
17
+ options?.map((option, index) => (
18
+ <>
19
+ <input
20
+ type="radio"
21
+ name={name}
22
+ required={required}
23
+ id={`${name}-${index}`}
24
+ value={option.value}
25
+ />
26
+ <label for={`${name}-${index}`}>{option.label}</label>
27
+ </>
28
+ ))
29
+ }
30
+ </fieldset>
@@ -0,0 +1,14 @@
1
+ ---
2
+ import Button from '@samuelgomez/astro/components/Button/index.astro';
3
+ import Info from '@samuelgomez/astro/icons/Info.astro';
4
+
5
+ type Props = {
6
+ moreInfo: string;
7
+ };
8
+
9
+ const { moreInfo } = Astro.props;
10
+ ---
11
+
12
+ <Button class="tooltip" variant="small" aria-label={moreInfo}>
13
+ <Info />
14
+ </Button>
@@ -0,0 +1,25 @@
1
+ ---
2
+ type Props = Partial<Omit<HTMLSelectElement, 'options'>> & {
3
+ ariaDescribedby?: string;
4
+ options: {
5
+ label: string;
6
+ value: string;
7
+ }[];
8
+ placeholder?: string;
9
+ placeholderValue?: string;
10
+ };
11
+
12
+ const {
13
+ name,
14
+ required = true,
15
+ id = name,
16
+ options,
17
+ placeholder = 'Sélectionner',
18
+ placeholderValue = '',
19
+ } = Astro.props;
20
+ ---
21
+
22
+ <select name={name} required={required} id={id}>
23
+ <option value={placeholderValue}>{placeholder}</option>
24
+ {options?.map(option => <option value={option.value}>{option.label}</option>)}
25
+ </select>
@@ -0,0 +1,34 @@
1
+ ---
2
+ import Cross from '@samuelgomez/astro/icons/Cross.astro';
3
+ import Check from '@samuelgomez/astro/icons/Check.astro';
4
+ type Props = {
5
+ id?: string;
6
+ help: string;
7
+ errorMessage?: string;
8
+ title?: string;
9
+ required?: boolean;
10
+ };
11
+
12
+ const {
13
+ help,
14
+ id,
15
+ errorMessage = 'Le champ est en erreur',
16
+ required = true,
17
+ title = undefined,
18
+ } = Astro.props;
19
+ ---
20
+
21
+ <span class="error-icon" aria-hidden="true"
22
+ ><Cross fill="var(--bc-error)" /></span
23
+ >
24
+ <span class="valid-icon" aria-hidden="true"
25
+ ><Check fill="var(--bc-success)" /></span
26
+ >
27
+ <span class="help-message" id={`help-${id}`}>
28
+ {help}
29
+ {required ? ' (champ obligatoire)' : ' (champ optionnel)'}
30
+ </span>
31
+ <span role="alert" class="error-message">
32
+ {errorMessage}
33
+ {Boolean(title) && ` : ${title}`}
34
+ </span>
@@ -0,0 +1,26 @@
1
+ ---
2
+ type Props = Partial<HTMLTextAreaElement> & {
3
+ ariaDescribedby?: string;
4
+ };
5
+
6
+ const {
7
+ name,
8
+ required = true,
9
+ id = name,
10
+ value,
11
+ rows = '5',
12
+ cols = '5',
13
+ ariaDescribedby = `help-${id}`,
14
+ } = Astro.props;
15
+ ---
16
+
17
+ <textarea
18
+ value={value}
19
+ name={name}
20
+ required={required}
21
+ id={id}
22
+ rows={rows}
23
+ cols={cols}
24
+ aria-describedby={ariaDescribedby}
25
+ spellcheck="true"
26
+ lang="fr"></textarea>
@@ -0,0 +1,23 @@
1
+ ---
2
+ import type { HTMLTag } from 'astro/types';
3
+
4
+ type Props = {
5
+ condition?: boolean;
6
+ wrapper?: HTMLTag;
7
+ class?: string;
8
+ };
9
+
10
+ const { condition, wrapper: Wrapper = 'div', ...rest } = Astro.props;
11
+ ---
12
+
13
+ {
14
+ condition ? (
15
+ <Wrapper {...rest}>
16
+ <slot />
17
+ </Wrapper>
18
+ ) : (
19
+ <>
20
+ <slot />
21
+ </>
22
+ )
23
+ }
@@ -0,0 +1,3 @@
1
+ <footer>
2
+ <p>&copy; Samuel Gomez 2024</p>
3
+ </footer>