webcoreui 0.0.6 → 0.0.8

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 (38) hide show
  1. package/README.md +4 -0
  2. package/astro.d.ts +6 -0
  3. package/astro.js +6 -0
  4. package/components/Accordion/Accordion.astro +5 -8
  5. package/components/Accordion/Accordion.svelte +2 -5
  6. package/components/Accordion/Accordion.tsx +1 -1
  7. package/components/Accordion/accordion.scss +1 -1
  8. package/components/Alert/Alert.astro +64 -0
  9. package/components/Alert/Alert.svelte +58 -0
  10. package/components/Alert/Alert.tsx +57 -0
  11. package/components/Alert/alert.scss +52 -0
  12. package/components/Alert/alert.ts +13 -0
  13. package/components/Badge/Badge.astro +27 -0
  14. package/components/Badge/Badge.svelte +20 -0
  15. package/components/Badge/Badge.tsx +19 -0
  16. package/components/Badge/badge.scss +85 -0
  17. package/components/Badge/badge.ts +12 -0
  18. package/components/Button/button.scss +5 -5
  19. package/components/Card/Card.astro +4 -9
  20. package/components/Card/Card.svelte +35 -0
  21. package/components/Card/Card.tsx +32 -1
  22. package/components/Card/card.scss +1 -1
  23. package/components/Card/card.ts +8 -1
  24. package/components/ConditionalWrapper/ConditionalWrapper.astro +17 -0
  25. package/components/ConditionalWrapper/ConditionalWrapper.svelte +14 -0
  26. package/components/ConditionalWrapper/ConditionalWrapper.tsx +13 -0
  27. package/components/ConditionalWrapper/conditionalwrapper.ts +3 -0
  28. package/components/Icon/Icon.svelte +3 -3
  29. package/components/Icon/Icon.tsx +2 -2
  30. package/icons/alert.svg +3 -0
  31. package/icons/check.svg +4 -0
  32. package/icons/info.svg +4 -0
  33. package/icons/warning.svg +4 -0
  34. package/package.json +1 -1
  35. package/react.d.ts +6 -0
  36. package/react.js +6 -0
  37. package/svelte.d.ts +6 -0
  38. package/svelte.js +6 -0
package/README.md CHANGED
@@ -132,5 +132,9 @@ import { Accordion } from 'webcoreui/react'
132
132
  ## Components
133
133
 
134
134
  - [Accordion](https://github.com/Frontendland/webcoreui/tree/main/src/components/Accordion)
135
+ - [Alert](https://github.com/Frontendland/webcoreui/tree/main/src/components/Alert)
136
+ - [ConditionalWrapper](https://github.com/Frontendland/webcoreui/tree/main/src/components/ConditionalWrapper)
137
+ - [Badge](https://github.com/Frontendland/webcoreui/tree/main/src/components/Badge)
135
138
  - [Button](https://github.com/Frontendland/webcoreui/tree/main/src/components/Button)
136
139
  - [Card](https://github.com/Frontendland/webcoreui/tree/main/src/components/Card)
140
+ - [Icon](https://github.com/Frontendland/webcoreui/tree/main/src/components/Icon)
package/astro.d.ts CHANGED
@@ -1,13 +1,19 @@
1
1
 
2
2
  declare module 'webcoreui/astro' {
3
3
  import type { AccordionProps } from './components/Accordion/accordion'
4
+ import type { AlertProps } from './components/Alert/alert'
5
+ import type { BadgeProps } from './components/Badge/badge'
4
6
  import type { ButtonProps } from './components/Button/button'
5
7
  import type { CardProps } from './components/Card/card'
8
+ import type { ConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
6
9
  import type { IconProps } from './components/Icon/icon'
7
10
 
8
11
  export function Accordion(_props: AccordionProps): any
12
+ export function Alert(_props: AlertProps): any
13
+ export function Badge(_props: BadgeProps): any
9
14
  export function Button(_props: ButtonProps): any
10
15
  export function Card(_props: CardProps): any
16
+ export function ConditionalWrapper(_props: ConditionalWrapperProps): any
11
17
  export function Icon(_props: IconProps): any
12
18
  }
13
19
 
package/astro.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import AccordionComponent from './components/Accordion/Accordion.astro'
2
+ import AlertComponent from './components/Alert/Alert.astro'
3
+ import BadgeComponent from './components/Badge/Badge.astro'
2
4
  import ButtonComponent from './components/Button/Button.astro'
3
5
  import CardComponent from './components/Card/Card.astro'
6
+ import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.astro'
4
7
  import IconComponent from './components/Icon/Icon.astro'
5
8
 
6
9
  export const Accordion = AccordionComponent
10
+ export const Alert = AlertComponent
11
+ export const Badge = BadgeComponent
7
12
  export const Button = ButtonComponent
8
13
  export const Card = CardComponent
14
+ export const ConditionalWrapper = ConditionalWrapperComponent
9
15
  export const Icon = IconComponent
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import type { AccordionProps } from './accordion'
3
- import Icon from '../Icon/Icon.astro'
3
+ import ArrowDown from '../../icons/arrow-down.svg?raw'
4
+ import './accordion.scss'
4
5
 
5
6
  interface Props extends AccordionProps {}
6
7
 
@@ -9,12 +10,12 @@ const {
9
10
  } = Astro.props
10
11
  ---
11
12
 
12
- <ul data-id="accordion">
13
+ <ul class="w-accordion" data-id="w-accordion">
13
14
  {items.map((item: AccordionProps['items'][0]) => (
14
15
  <li>
15
16
  <div class="accordion-title">
16
17
  {item.title}
17
- <Icon type="arrow-down" size={15} />
18
+ <Fragment set:html={ArrowDown} />
18
19
  </div>
19
20
  <div class="accordion-wrapper">
20
21
  <div class="accordion-content">
@@ -26,7 +27,7 @@ const {
26
27
  </ul>
27
28
 
28
29
  <script>
29
- const accordions = document.querySelectorAll('[data-id="accordion"]')
30
+ const accordions = document.querySelectorAll('[data-id="w-accordion"]')
30
31
 
31
32
  Array.from(accordions).forEach(element => {
32
33
  element.addEventListener('click', event => {
@@ -38,7 +39,3 @@ const {
38
39
  })
39
40
  })
40
41
  </script>
41
-
42
- <style lang="scss">
43
- @import './accordion.scss';
44
- </style>
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { AccordionProps } from './accordion'
3
3
  import ArrowDown from '../../icons/arrow-down.svg?raw'
4
+ import './accordion.scss'
4
5
 
5
6
  export let items: AccordionProps['items']
6
7
 
@@ -14,7 +15,7 @@
14
15
  }
15
16
  </script>
16
17
 
17
- <ul>
18
+ <ul class="w-accordion">
18
19
  {#each items as item, index}
19
20
  <li>
20
21
  <div
@@ -33,7 +34,3 @@
33
34
  </li>
34
35
  {/each}
35
36
  </ul>
36
-
37
- <style lang="scss">
38
- @import './accordion.scss';
39
- </style>
@@ -14,7 +14,7 @@ const Accordion = ({ items }: AccordionProps) => {
14
14
  }
15
15
 
16
16
  return (
17
- <ul data-id="accordion">
17
+ <ul className="w-accordion">
18
18
  {items.map((item, index) => (
19
19
  <li key={index}>
20
20
  <div
@@ -1,6 +1,6 @@
1
1
  @import '../../scss/config.scss';
2
2
 
3
- ul {
3
+ .w-accordion {
4
4
  margin: 0;
5
5
  padding: 0;
6
6
  list-style-type: none;
@@ -0,0 +1,64 @@
1
+ ---
2
+ import type { AlertProps } from './alert'
3
+ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
4
+
5
+ import info from '../../icons/info.svg?raw'
6
+ import success from '../../icons/check.svg?raw'
7
+ import warning from '../../icons/warning.svg?raw'
8
+ import alert from '../../icons/alert.svg?raw'
9
+
10
+ interface Props extends AlertProps {}
11
+
12
+ const iconMap = {
13
+ info,
14
+ success,
15
+ warning,
16
+ alert
17
+ }
18
+
19
+ const {
20
+ element = 'section',
21
+ title,
22
+ titleTag = 'strong',
23
+ className,
24
+ theme,
25
+ ...rest
26
+ } = Astro.props
27
+
28
+ const Component = element
29
+ const Title = titleTag
30
+ const hasCustomIcon = Astro.slots.has('icon')
31
+
32
+ const classes = [
33
+ 'w-alert',
34
+ (!hasCustomIcon && !theme) && 'col',
35
+ theme,
36
+ className
37
+ ].filter(Boolean).join(' ')
38
+
39
+ const props = {
40
+ class: classes
41
+ }
42
+ ---
43
+
44
+ <Component {...props} {...rest}>
45
+ <slot name="icon" />
46
+
47
+ {!hasCustomIcon && theme && <Fragment set:html={iconMap[theme]} />}
48
+
49
+ <ConditionalWrapper condition={!!(hasCustomIcon || theme)}>
50
+ <div class="alert-wrapper" slot="wrapper">
51
+ children
52
+ </div>
53
+ {title && (
54
+ <Title class:list="alert-title">{title}</Title>
55
+ )}
56
+ <div class="alert-body">
57
+ <slot />
58
+ </div>
59
+ </ConditionalWrapper>
60
+ </Component>
61
+
62
+ <style lang="scss">
63
+ @import './alert.scss';
64
+ </style>
@@ -0,0 +1,58 @@
1
+ <script lang="ts">
2
+ import type { AlertProps } from './alert'
3
+ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
4
+
5
+ import info from '../../icons/info.svg?raw'
6
+ import success from '../../icons/check.svg?raw'
7
+ import warning from '../../icons/warning.svg?raw'
8
+ import alert from '../../icons/alert.svg?raw'
9
+
10
+ export let element: AlertProps['element'] = 'section'
11
+ export let title: AlertProps['title'] = null
12
+ export let titleTag: AlertProps['title'] = 'strong'
13
+ export let className: AlertProps['className'] = null
14
+ export let theme: AlertProps['theme'] = null
15
+
16
+ const iconMap = {
17
+ info,
18
+ success,
19
+ warning,
20
+ alert
21
+ }
22
+
23
+ const hasCustomIcon = $$slots.icon
24
+
25
+ const classes = [
26
+ 'w-alert',
27
+ (!hasCustomIcon && !theme) && 'col',
28
+ theme,
29
+ className
30
+ ].filter(Boolean).join(' ')
31
+ </script>
32
+
33
+ <svelte:element this={element} class={classes} {...$$restProps}>
34
+ <slot name="icon" />
35
+
36
+ {#if !hasCustomIcon && theme}
37
+ {@html iconMap[theme]}
38
+ {/if}
39
+
40
+ <ConditionalWrapper
41
+ condition={!!(hasCustomIcon || theme)}
42
+ element="div"
43
+ class="alert-wrapper"
44
+ >
45
+ {#if title}
46
+ <svelte:element this={titleTag} class="alert-title">
47
+ {title}
48
+ </svelte:element>
49
+ {/if}
50
+ <div class="alert-body">
51
+ <slot />
52
+ </div>
53
+ </ConditionalWrapper>
54
+ </svelte:element>
55
+
56
+ <style lang="scss">
57
+ @import './alert.scss';
58
+ </style>
@@ -0,0 +1,57 @@
1
+ import React from 'react'
2
+ import type { AlertProps } from './alert'
3
+ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
4
+
5
+ import info from '../../icons/info.svg?raw'
6
+ import success from '../../icons/check.svg?raw'
7
+ import warning from '../../icons/warning.svg?raw'
8
+ import alert from '../../icons/alert.svg?raw'
9
+
10
+ import './alert.scss'
11
+
12
+ const iconMap = {
13
+ info,
14
+ success,
15
+ warning,
16
+ alert
17
+ }
18
+
19
+ const Alert = ({
20
+ Element = 'section',
21
+ title,
22
+ TitleTag = 'strong',
23
+ className,
24
+ theme,
25
+ children,
26
+ icon,
27
+ ...rest
28
+ }: AlertProps & { icon?: any }) => {
29
+ const classes = [
30
+ 'w-alert',
31
+ (!icon && !theme) && 'col',
32
+ theme,
33
+ className
34
+ ].filter(Boolean).join(' ')
35
+
36
+ return (
37
+ <Element className={classes} {...rest}>
38
+ {icon && icon}
39
+ {!icon && theme && <div dangerouslySetInnerHTML={{ __html: iconMap[theme] }} />}
40
+
41
+ <ConditionalWrapper condition={!!(icon || theme)} wrapper={children => (
42
+ <div className="alert-wrapper">
43
+ {children}
44
+ </div>
45
+ )}>
46
+ {title && (
47
+ <TitleTag className="alert-title">{title}</TitleTag>
48
+ )}
49
+ <div className="alert-body">
50
+ {children}
51
+ </div>
52
+ </ConditionalWrapper>
53
+ </Element>
54
+ )
55
+ }
56
+
57
+ export default Alert
@@ -0,0 +1,52 @@
1
+ @import '../../scss/config.scss';
2
+
3
+ .w-alert {
4
+ border: 1px solid #252525;
5
+ border-radius: 5px;
6
+ padding: 15px;
7
+ display: flex;
8
+
9
+ &.col {
10
+ flex-direction: column;
11
+ }
12
+
13
+ &:not(.col) {
14
+ gap: 10px;
15
+ }
16
+
17
+ &.info {
18
+ border: 1px solid #0abde3;
19
+ color: #0abde3;
20
+ }
21
+
22
+ &.success {
23
+ border: 1px solid #1dd1a1;
24
+ color: #1dd1a1;
25
+ }
26
+
27
+ &.warning {
28
+ border: 1px solid #ff9f43;
29
+ color: #ff9f43;
30
+ }
31
+
32
+ &.alert {
33
+ border: 1px solid #e73f40;
34
+ color: #e73f40;
35
+ }
36
+
37
+ svg {
38
+ width: 20px;
39
+ height: 20px;
40
+ margin-top: 1px;
41
+ }
42
+
43
+ .alert-title {
44
+ display: block;
45
+ margin-bottom: 5px;
46
+ }
47
+
48
+ .alert-body {
49
+ font-size: 16px;
50
+ color: #BBB;
51
+ }
52
+ }
@@ -0,0 +1,13 @@
1
+ export type AlertProps = {
2
+ element?: string
3
+ title?: string | null
4
+ titleTag?: string
5
+ icon?: string | null
6
+ className?: string | null
7
+ theme?: 'info'
8
+ | 'success'
9
+ | 'warning'
10
+ | 'alert'
11
+ | null
12
+ [key: string]: any
13
+ }
@@ -0,0 +1,27 @@
1
+ ---
2
+ import type { BadgeProps } from './badge'
3
+
4
+ interface Props extends BadgeProps {
5
+ interactive?: boolean
6
+ }
7
+
8
+ const {
9
+ theme,
10
+ interactive
11
+ } = Astro.props
12
+
13
+ const classes = [
14
+ 'w-badge',
15
+ theme || null,
16
+ interactive && 'hover'
17
+ ]
18
+ ---
19
+
20
+ <span class:list={classes}>
21
+ <slot />
22
+ </span>
23
+
24
+
25
+ <style lang="scss">
26
+ @import './badge.scss';
27
+ </style>
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import type { BadgeProps } from './badge'
3
+
4
+ export let theme: BadgeProps['theme'] = null
5
+ export let onClick: BadgeProps['onClick'] = () => {}
6
+
7
+ const classes = [
8
+ 'w-badge',
9
+ theme || null,
10
+ onClick && 'hover'
11
+ ].filter(Boolean).join(' ')
12
+ </script>
13
+
14
+ <span class={classes} on:click={onClick}>
15
+ <slot />
16
+ </span>
17
+
18
+ <style lang="scss">
19
+ @import './badge.scss';
20
+ </style>
@@ -0,0 +1,19 @@
1
+ import React from 'react'
2
+ import type { BadgeProps } from './badge'
3
+ import './badge.scss'
4
+
5
+ const Badge = ({ theme, onClick, children }: BadgeProps) => {
6
+ const classes = [
7
+ 'w-badge',
8
+ theme || null,
9
+ onClick && 'hover'
10
+ ].filter(Boolean).join(' ')
11
+
12
+ return (
13
+ <span className={classes} onClick={onClick}>
14
+ {children}
15
+ </span>
16
+ )
17
+ }
18
+
19
+ export default Badge
@@ -0,0 +1,85 @@
1
+ @import '../../scss/config.scss';
2
+
3
+ .w-badge {
4
+ @include Transition();
5
+ padding: 5px 10px;
6
+ border-radius: 5px;
7
+ display: inline-flex;
8
+ align-items: center;
9
+ gap: 5px;
10
+ font-size: 12px;
11
+ background: #FFF;
12
+ color: #252525;
13
+
14
+ &.hover {
15
+ cursor: pointer;
16
+
17
+ &:hover {
18
+ background: #BBB;
19
+ }
20
+
21
+ &.secondary:hover {
22
+ background: #333;
23
+ }
24
+
25
+ &.outline:hover {
26
+ color: #FFF;
27
+ background: transparent;
28
+ box-shadow: inset 0px 0px 0px 1px #FFF;
29
+ }
30
+
31
+ &.flat:hover {
32
+ background: #333;
33
+ }
34
+
35
+ &.info:hover {
36
+ background: #48dbfb;
37
+ }
38
+
39
+ &.success:hover {
40
+ background: #1dd1a1;
41
+ }
42
+
43
+ &.warning:hover {
44
+ background: #f7aa61;
45
+ }
46
+
47
+ &.alert:hover {
48
+ background: #ee5253;
49
+ }
50
+ }
51
+
52
+
53
+ &.secondary {
54
+ background: #252525;
55
+ color: #FFF;
56
+ }
57
+
58
+ &.outline {
59
+ background: #000;
60
+ color: #BBB;
61
+ box-shadow: inset 0px 0px 0px 1px #BBB;
62
+ }
63
+
64
+ &.flat {
65
+ background: #000;
66
+ color: #FFF;
67
+ }
68
+
69
+ &.info {
70
+ background: #0abde3;
71
+ }
72
+
73
+ &.success {
74
+ background: #10ac84;
75
+ }
76
+
77
+ &.warning {
78
+ background: #ff9f43;
79
+ }
80
+
81
+ &.alert {
82
+ background: #e73f40;
83
+ color: #fff;
84
+ }
85
+ }
@@ -0,0 +1,12 @@
1
+ export type BadgeProps = {
2
+ theme?: 'secondary'
3
+ | 'outline'
4
+ | 'flat'
5
+ | 'info'
6
+ | 'success'
7
+ | 'warning'
8
+ | 'alert'
9
+ | null
10
+ onClick?: () => any
11
+ [key: string]: any
12
+ }
@@ -35,12 +35,12 @@
35
35
 
36
36
  &.outline {
37
37
  background: #000;
38
- color: #FFF;
39
- box-shadow: inset 0px 0px 0px 1px #FFF;
40
-
38
+ color: #BBB;
39
+ box-shadow: inset 0px 0px 0px 1px #BBB;
40
+
41
41
  &:hover {
42
- color: #BBB;
43
- box-shadow: inset 0px 0px 0px 1px #BBB;
42
+ color: #FFF;
43
+ box-shadow: inset 0px 0px 0px 1px #FFF;
44
44
  }
45
45
  }
46
46
 
@@ -1,12 +1,7 @@
1
1
  ---
2
- interface Props {
3
- element?: string
4
- title?: string
5
- compact?: boolean
6
- className?: string
7
- secondary?: boolean
8
- [key: string]: any
9
- }
2
+ import type { CardProps } from './card'
3
+
4
+ interface Props extends CardProps {}
10
5
 
11
6
  const {
12
7
  element = 'section',
@@ -19,9 +14,9 @@ const {
19
14
  } = Astro.props
20
15
 
21
16
  const classes = [
17
+ 'w-card',
22
18
  className,
23
19
  secondary && 'secondary',
24
- 'card'
25
20
  ].filter(Boolean).join(' ')
26
21
 
27
22
  const props = {
@@ -0,0 +1,35 @@
1
+ <script lang="ts">
2
+ import type { CardProps } from './card'
3
+
4
+ export let element: CardProps['element'] = 'section'
5
+ export let title: CardProps['title'] = ''
6
+ export let titleTag: CardProps['titleTag'] = 'span'
7
+ export let compact: CardProps['compact'] = false
8
+ export let className: CardProps['className'] = ''
9
+ export let secondary: CardProps['secondary'] = false
10
+
11
+ const classes = [
12
+ 'w-card',
13
+ className,
14
+ secondary && 'secondary'
15
+ ].filter(Boolean).join(' ')
16
+ </script>
17
+
18
+ <svelte:element this={element} class={classes} {...$$restProps}>
19
+ {#if title}
20
+ <svelte:element this={titleTag} class="card-title">
21
+ {title}
22
+ </svelte:element>
23
+ {/if}
24
+ <div class="card-body" class:compact>
25
+ {#if compact && !secondary}
26
+ <div class="card-wrapper"><slot /></div>
27
+ {:else}
28
+ <slot />
29
+ {/if}
30
+ </div>
31
+ </svelte:element>
32
+
33
+ <style lang="scss">
34
+ @import './card.scss';
35
+ </style>
@@ -1,5 +1,36 @@
1
1
  import React from 'react'
2
+ import type { CardProps } from './card'
3
+ import './card.scss'
2
4
 
3
- const Card = () => <div />
5
+ const Card = ({
6
+ Element = 'section',
7
+ title,
8
+ TitleTag = 'span',
9
+ compact,
10
+ className,
11
+ secondary,
12
+ children,
13
+ ...rest
14
+ }: CardProps) => {
15
+ const classes = [
16
+ 'w-card',
17
+ className,
18
+ secondary && 'secondary'
19
+ ].filter(Boolean).join(' ')
20
+
21
+ return (
22
+ <Element className={classes} {...rest}>
23
+ {title && (
24
+ <TitleTag className="card-title">{title}</TitleTag>
25
+ )}
26
+ <div className={compact ? 'card-body compact' : 'card-body'}>
27
+ {compact && !secondary
28
+ ? <div className="card-wrapper">{children}</div>
29
+ : children
30
+ }
31
+ </div>
32
+ </Element>
33
+ )
34
+ }
4
35
 
5
36
  export default Card
@@ -1,4 +1,4 @@
1
- .card {
1
+ .w-card {
2
2
  border: 1px solid #252525;
3
3
  border-radius: 5px;
4
4
  display: flex;
@@ -1 +1,8 @@
1
- export type CardProps = {}
1
+ export type CardProps = {
2
+ element?: string
3
+ title?: string
4
+ compact?: boolean
5
+ className?: string
6
+ secondary?: boolean
7
+ [key: string]: any
8
+ }
@@ -0,0 +1,17 @@
1
+ ---
2
+ import type { ConditionalWrapperProps } from './conditionalwrapper'
3
+
4
+ interface Props extends ConditionalWrapperProps {}
5
+
6
+ const { condition } = Astro.props
7
+
8
+ const wrapper = await Astro.slots.render('wrapper')
9
+ const children = await Astro.slots.render('default')
10
+ const wrapped = wrapper?.replace('children', children)
11
+
12
+ if (!Astro.slots.has('wrapper')) {
13
+ console.error('Missing wrapper. Add slot="wrapper" to one of the elements.')
14
+ }
15
+ ---
16
+
17
+ <Fragment set:html={condition ? wrapped : children} />
@@ -0,0 +1,14 @@
1
+ <script lang="ts">
2
+ import type { ConditionalWrapperProps } from './conditionalwrapper'
3
+
4
+ export let condition: ConditionalWrapperProps['condition']
5
+ export let element: string
6
+ </script>
7
+
8
+ {#if condition}
9
+ <svelte:element this={element} {...$$restProps}>
10
+ <slot />
11
+ </svelte:element>
12
+ {:else}
13
+ <slot />
14
+ {/if}
@@ -0,0 +1,13 @@
1
+ import React from 'react'
2
+ import type { ConditionalWrapperProps } from './conditionalwrapper'
3
+
4
+ type ExtendedConditionalWrapperProps = {
5
+ condition: ConditionalWrapperProps['condition']
6
+ wrapper: (_: React.ReactNode) => any
7
+ children: React.ReactNode
8
+ };
9
+
10
+ const ConditionalWrapper = ({ condition, wrapper, children }: ExtendedConditionalWrapperProps) =>
11
+ condition ? wrapper(children) : children
12
+
13
+ export default ConditionalWrapper
@@ -0,0 +1,3 @@
1
+ export type ConditionalWrapperProps = {
2
+ condition: boolean
3
+ }
@@ -4,16 +4,16 @@
4
4
  import Github from '../../icons/github.svg?raw'
5
5
  import ArrowDown from '../../icons/arrow-down.svg?raw'
6
6
 
7
- export let type: IconProps['type']
7
+ export let type: IconProps['type'] = ''
8
8
  export let size: IconProps['size'] = 24
9
- export let color: IconProps['color']
9
+ export let color: IconProps['color'] = ''
10
10
 
11
11
  const iconMap = {
12
12
  'github': Github,
13
13
  'arrow-down': ArrowDown
14
14
  }
15
15
 
16
- const icon = iconMap[type]
16
+ const icon = iconMap[type as keyof typeof iconMap]
17
17
  .replace('width="24"', `width=${size}`)
18
18
  .replace('height="24"', color
19
19
  ? `height=${size} color=${color}`
@@ -14,13 +14,13 @@ const Icon = ({
14
14
  size = 24,
15
15
  color
16
16
  }: IconProps) => {
17
- const icon = iconMap[type]
17
+ const icon = iconMap[type as keyof typeof iconMap]
18
18
  .replace('width="24"', `width=${size}`)
19
19
  .replace('height="24"', color
20
20
  ? `height=${size} color=${color}`
21
21
  : `height=${size}`)
22
22
 
23
- return <div dangerouslySetInnerHTML={{ __html: icon }} />
23
+ return <span dangerouslySetInnerHTML={{ __html: icon }} />
24
24
  }
25
25
 
26
26
  export default Icon
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7.48872 2.15394C7.48856 2.1541 7.48888 2.15378 7.48872 2.15394L2.15302 7.48964C1.99269 7.64997 1.93416 7.74684 1.9045 7.81776C1.87504 7.88818 1.84615 7.99973 1.84615 8.23015V15.7698C1.84615 15.9963 1.8732 16.1054 1.90221 16.1759C1.93113 16.2463 1.9898 16.3459 2.15425 16.5104L7.48964 21.847C7.48966 21.847 7.48961 21.847 7.48964 21.847C7.64992 22.0073 7.74685 22.0658 7.81776 22.0955C7.88818 22.125 7.99973 22.1538 8.23015 22.1538H15.7698C15.9964 22.1538 16.1061 22.1268 16.1771 22.0976C16.2477 22.0687 16.3471 22.0102 16.5104 21.847L21.847 16.5104C22.0073 16.35 22.0658 16.2532 22.0955 16.1822C22.125 16.1118 22.1538 16.0003 22.1538 15.7698V8.23015C22.1538 8.00362 22.1268 7.89393 22.0976 7.82287C22.0687 7.75228 22.0102 7.65286 21.847 7.48964L16.5104 2.15302C16.3471 1.9898 16.2477 1.9313 16.1771 1.90235C16.1061 1.87321 15.9964 1.84615 15.7698 1.84615H8.23015C8.0037 1.84615 7.89439 1.87319 7.82354 1.90227C7.75298 1.93123 7.65289 1.99031 7.48872 2.15394ZM7.12261 0.194349C7.48962 0.0437307 7.85846 0 8.23015 0H15.7698C16.1415 0 16.5105 0.0437121 16.8776 0.194263C17.2452 0.345007 17.5433 0.575125 17.8158 0.847594L23.1524 6.18421C23.4249 6.45668 23.655 6.75479 23.8057 7.12236C23.9563 7.48946 24 7.85853 24 8.23015V15.7698C24 16.1548 23.952 16.5282 23.7987 16.8947C23.6455 17.2607 23.4155 17.5527 23.1524 17.8158L17.8158 23.1524C17.5433 23.4249 17.2452 23.655 16.8776 23.8057C16.5105 23.9563 16.1415 24 15.7698 24H8.23015C7.84519 24 7.47182 23.952 7.10532 23.7987C6.73932 23.6455 6.44726 23.4155 6.18421 23.1524L0.848825 17.8158C0.8488 17.8158 0.84885 17.8158 0.848825 17.8158C0.576388 17.5433 0.345783 17.2454 0.194714 16.8779C0.0437194 16.5106 0 16.1415 0 15.7698V8.23015C0 7.84519 0.0480391 7.47182 0.20135 7.10532C0.354452 6.73932 0.58454 6.44726 0.847594 6.18421L6.18513 0.846674C6.45759 0.574982 6.7554 0.345054 7.12261 0.194349ZM12 5.69477C12.5098 5.69477 12.9231 6.10804 12.9231 6.61785V13.3871C12.9231 13.8969 12.5098 14.3102 12 14.3102C11.4902 14.3102 11.0769 13.8969 11.0769 13.3871V6.61785C11.0769 6.10804 11.4902 5.69477 12 5.69477ZM12 15.8437C12.5098 15.8437 12.9231 16.257 12.9231 16.7668V17.3822C12.9231 17.892 12.5098 18.3052 12 18.3052C11.4902 18.3052 11.0769 17.892 11.0769 17.3822V16.7668C11.0769 16.257 11.4902 15.8437 12 15.8437Z" fill="currentColor"/>
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M16.6425 7.92858C17.0558 8.22704 17.1489 8.80404 16.8505 9.21734L12.4237 15.3474C12.4236 15.3475 12.4238 15.3473 12.4237 15.3474C12.2341 15.6102 11.9873 15.8271 11.7024 15.9814C11.4174 16.1357 11.1011 16.2237 10.7773 16.2389C10.4535 16.254 10.1304 16.1958 9.83224 16.0687C9.53413 15.9416 9.26855 15.7489 9.05527 15.5049C9.0552 15.5048 9.05534 15.505 9.05527 15.5049L7.20296 13.3867C6.86736 13.003 6.90641 12.4198 7.29017 12.0842C7.67393 11.7486 8.25709 11.7877 8.59268 12.1714L10.445 14.2896C10.4755 14.3245 10.5136 14.3522 10.5562 14.3704C10.5988 14.3886 10.645 14.3969 10.6912 14.3947C10.7375 14.3925 10.7827 14.38 10.8234 14.3579C10.8641 14.3359 10.8993 14.3049 10.9264 14.2674L15.3538 8.13651C15.6522 7.72321 16.2292 7.63012 16.6425 7.92858Z" fill="currentColor"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12 1.84615C6.39219 1.84615 1.84615 6.39219 1.84615 12C1.84615 17.6078 6.39219 22.1538 12 22.1538C17.6078 22.1538 22.1538 17.6078 22.1538 12C22.1538 6.39219 17.6078 1.84615 12 1.84615ZM0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12Z" fill="currentColor"/>
4
+ </svg>
package/icons/info.svg ADDED
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12 6.15381C12.5098 6.15381 12.9231 6.56708 12.9231 7.07689V7.69227C12.9231 8.20207 12.5098 8.61535 12 8.61535C11.4902 8.61535 11.0769 8.20207 11.0769 7.69227V7.07689C11.0769 6.56708 11.4902 6.15381 12 6.15381ZM10.4615 10.7692C10.4615 10.2594 10.8748 9.84612 11.3846 9.84612H12C12.5098 9.84612 12.9231 10.2594 12.9231 10.7692V16.0525C13.2816 16.1792 13.5385 16.5211 13.5385 16.923C13.5385 17.4328 13.1252 17.8461 12.6154 17.8461H11.3846C10.8748 17.8461 10.4615 17.4328 10.4615 16.923C10.4615 16.5211 10.7184 16.1792 11.0769 16.0525V11.6397C10.7184 11.513 10.4615 11.1711 10.4615 10.7692Z" fill="currentColor"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M18.5084 0.0701433C17.6498 -1.24757e-05 16.5847 -6.90184e-06 15.2406 1.40675e-07H8.75939C7.41534 -6.90184e-06 6.3502 -1.24757e-05 5.4916 0.0701433C4.61356 0.141887 3.87051 0.291634 3.192 0.63723C2.09202 1.19771 1.19765 2.09215 0.637165 3.19213C0.29157 3.87064 0.141887 4.61356 0.0701433 5.4916C-1.24757e-05 6.3502 -6.90184e-06 7.41534 1.40675e-07 8.75939V15.2406C-6.90184e-06 16.5847 -1.24757e-05 17.6498 0.0701433 18.5084C0.141887 19.3864 0.291634 20.1295 0.63723 20.808C1.19771 21.908 2.09215 22.8024 3.19213 23.3628C3.87064 23.7084 4.61356 23.8581 5.4916 23.9299C6.35019 24 7.41532 24 8.75937 24H15.2406C16.5847 24 17.6498 24 18.5084 23.9299C19.3864 23.8581 20.1295 23.7084 20.808 23.3628C21.908 22.8023 22.8024 21.9078 23.3628 20.8079C23.7084 20.1294 23.8581 19.3864 23.9299 18.5084C24 17.6498 24 16.5847 24 15.2406V8.75937C24 7.41532 24 6.35019 23.9299 5.4916C23.8581 4.61356 23.7084 3.87051 23.3628 3.192C22.8023 2.09202 21.9079 1.19765 20.8079 0.637165C20.1294 0.29157 19.3864 0.141887 18.5084 0.0701433ZM4.03016 2.28216C4.40516 2.09117 4.87822 1.97257 5.64194 1.91017C6.41655 1.84687 7.40631 1.84615 8.8 1.84615H15.2C16.5937 1.84615 17.5834 1.84687 18.3581 1.91017C19.1219 1.97258 19.5949 2.0912 19.97 2.28222C20.7225 2.66571 21.3344 3.27758 21.7178 4.03016C21.9088 4.40516 22.0274 4.87822 22.0898 5.64194C22.1531 6.41656 22.1538 7.40631 22.1538 8.8V15.2C22.1538 16.5937 22.1531 17.5834 22.0898 18.3581C22.0274 19.1218 21.9088 19.5948 21.7178 19.9698C21.3344 20.7225 20.7225 21.3344 19.9698 21.7178C19.5948 21.9088 19.1218 22.0274 18.3581 22.0898C17.5834 22.1531 16.5937 22.1538 15.2 22.1538H8.8C7.40631 22.1538 6.41656 22.1531 5.64194 22.0898C4.87822 22.0274 4.40516 21.9088 4.03016 21.7178C3.27758 21.3344 2.66571 20.7225 2.28222 19.97C2.0912 19.5949 1.97258 19.1219 1.91017 18.3581C1.84687 17.5834 1.84615 16.5937 1.84615 15.2V8.8C1.84615 7.40631 1.84687 6.41655 1.91017 5.64194C1.97257 4.87822 2.09117 4.40516 2.28216 4.03016C2.66563 3.27764 3.27764 2.66563 4.03016 2.28216Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M11.9222 8.23694C12.395 8.23694 12.7784 8.62029 12.7784 9.09318V15.3722C12.7784 15.8451 12.395 16.2284 11.9222 16.2284C11.4493 16.2284 11.0659 15.8451 11.0659 15.3722V9.09318C11.0659 8.62029 11.4493 8.23694 11.9222 8.23694ZM11.9222 17.652C12.395 17.652 12.7784 18.0354 12.7784 18.5083V19.0791C12.7784 19.552 12.395 19.9353 11.9222 19.9353C11.4493 19.9353 11.0659 19.552 11.0659 19.0791V18.5083C11.0659 18.0354 11.4493 17.652 11.9222 17.652Z" fill="currentColor"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21.8974 18.9385L13.639 3.83981C12.9304 2.54425 11.0696 2.54425 10.361 3.83981L2.10258 18.9385C1.42165 20.1834 2.32258 21.7031 3.74156 21.7031H20.2584C21.6774 21.7031 22.5784 20.1834 21.8974 18.9385ZM15.278 2.94334C13.8607 0.35222 10.1393 0.35222 8.72202 2.94334L0.463591 18.042C-0.898272 20.5319 0.903593 23.5712 3.74156 23.5712H20.2584C23.0964 23.5712 24.8983 20.5319 23.5364 18.042L15.278 2.94334Z" fill="currentColor"/>
4
+ </svg>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webcoreui",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "scripts": {
6
6
  "dev": "astro dev",
7
7
  "build": "astro check && astro build",
package/react.d.ts CHANGED
@@ -1,13 +1,19 @@
1
1
 
2
2
  declare module 'webcoreui/react' {
3
3
  import type { AccordionProps } from './components/Accordion/accordion'
4
+ import type { AlertProps } from './components/Alert/alert'
5
+ import type { BadgeProps } from './components/Badge/badge'
4
6
  import type { ButtonProps } from './components/Button/button'
5
7
  import type { CardProps } from './components/Card/card'
8
+ import type { ConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
6
9
  import type { IconProps } from './components/Icon/icon'
7
10
 
8
11
  export function Accordion(_props: AccordionProps): any
12
+ export function Alert(_props: AlertProps): any
13
+ export function Badge(_props: BadgeProps): any
9
14
  export function Button(_props: ButtonProps): any
10
15
  export function Card(_props: CardProps): any
16
+ export function ConditionalWrapper(_props: ConditionalWrapperProps): any
11
17
  export function Icon(_props: IconProps): any
12
18
  }
13
19
 
package/react.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import AccordionComponent from './components/Accordion/Accordion.tsx'
2
+ import AlertComponent from './components/Alert/Alert.tsx'
3
+ import BadgeComponent from './components/Badge/Badge.tsx'
2
4
  import ButtonComponent from './components/Button/Button.tsx'
3
5
  import CardComponent from './components/Card/Card.tsx'
6
+ import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.tsx'
4
7
  import IconComponent from './components/Icon/Icon.tsx'
5
8
 
6
9
  export const Accordion = AccordionComponent
10
+ export const Alert = AlertComponent
11
+ export const Badge = BadgeComponent
7
12
  export const Button = ButtonComponent
8
13
  export const Card = CardComponent
14
+ export const ConditionalWrapper = ConditionalWrapperComponent
9
15
  export const Icon = IconComponent
package/svelte.d.ts CHANGED
@@ -1,13 +1,19 @@
1
1
 
2
2
  declare module 'webcoreui/svelte' {
3
3
  import type { AccordionProps } from './components/Accordion/accordion'
4
+ import type { AlertProps } from './components/Alert/alert'
5
+ import type { BadgeProps } from './components/Badge/badge'
4
6
  import type { ButtonProps } from './components/Button/button'
5
7
  import type { CardProps } from './components/Card/card'
8
+ import type { ConditionalWrapperProps } from './components/ConditionalWrapper/conditionalwrapper'
6
9
  import type { IconProps } from './components/Icon/icon'
7
10
 
8
11
  export function Accordion(_props: AccordionProps): any
12
+ export function Alert(_props: AlertProps): any
13
+ export function Badge(_props: BadgeProps): any
9
14
  export function Button(_props: ButtonProps): any
10
15
  export function Card(_props: CardProps): any
16
+ export function ConditionalWrapper(_props: ConditionalWrapperProps): any
11
17
  export function Icon(_props: IconProps): any
12
18
  }
13
19
 
package/svelte.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import AccordionComponent from './components/Accordion/Accordion.svelte'
2
+ import AlertComponent from './components/Alert/Alert.svelte'
3
+ import BadgeComponent from './components/Badge/Badge.svelte'
2
4
  import ButtonComponent from './components/Button/Button.svelte'
3
5
  import CardComponent from './components/Card/Card.svelte'
6
+ import ConditionalWrapperComponent from './components/ConditionalWrapper/ConditionalWrapper.svelte'
4
7
  import IconComponent from './components/Icon/Icon.svelte'
5
8
 
6
9
  export const Accordion = AccordionComponent
10
+ export const Alert = AlertComponent
11
+ export const Badge = BadgeComponent
7
12
  export const Button = ButtonComponent
8
13
  export const Card = CardComponent
14
+ export const ConditionalWrapper = ConditionalWrapperComponent
9
15
  export const Icon = IconComponent