webcoreui 0.0.3 → 0.0.5

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Frontendland
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ <p>
2
+ <a href="https://webcoreui.dev">
3
+ <img
4
+ alt="Webcore - Frontend components for Astro, Svelte, and React"
5
+ src="https://raw.githubusercontent.com/Frontendland/webcoreui/main/public/img/banner.png"
6
+ />
7
+ </a>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://github.com/Frontendland/webcoreui/releases">
12
+ <img
13
+ src="https://img.shields.io/npm/v/webcoreui.svg?label=Latest%20Release"
14
+ alt="Latest Release"
15
+ />
16
+ </a>
17
+ <a href="https://github.com/Frontendland/webcoreui/blob/main/LICENSE">
18
+ <img
19
+ src="https://img.shields.io/badge/license-MIT-blue"
20
+ alt="License"
21
+ />
22
+ </a>
23
+ </p>
24
+
25
+ > [!IMPORTANT]
26
+ > This library is still in early development. New changes can break existing functionality, and no functionality should be considered final. The library will be considered stable once it reaches v1.0.
27
+
28
+ ---
29
+ ## Table of Contents
30
+
31
+ - [Table of Contents](#table-of-contents)
32
+ - [Documentation](#documentation)
33
+ - [Getting started](#getting-started)
34
+ - [Prerequisites](#prerequisites)
35
+ - [Installation](#installation)
36
+ - [Setup](#setup)
37
+ - [Using Components](#using-components)
38
+ - [Components](#components)
39
+
40
+ ## Documentation
41
+
42
+ Full documentation coming soon on [webcoreui.dev/docs](https://webcoreui.dev/docs).
43
+
44
+ ## Getting Started
45
+
46
+ Webcore can be used as a standalone project, or it can be integrated into your existing Astro, Svelte, or React ecosystems.
47
+
48
+ ### Prerequisites
49
+
50
+ > [!NOTE]
51
+ > Before getting started, make sure you have a package manager installed, such as <a href="https://nodejs.org/en/" rel="noreferrer">Node</a>.
52
+
53
+ Webcore components use Sass for styling. To use the component library, you must have the following packages installed:
54
+
55
+ - [Sass](https://www.npmjs.com/package/sass) - `v1.77` and above
56
+ - [TypeScript](https://www.npmjs.com/package/typescript) - `v5.4` and above
57
+
58
+ Depending on your project setup, you'll also need the following packages:
59
+
60
+ - **For Astro projects**
61
+ - [Astro](https://www.npmjs.com/package/astro) - `v4.10` and above
62
+ - **For Svelte projects**
63
+ - [Svelte](https://www.npmjs.com/package/svelte) - `v4.2` and above
64
+ - **For React projects**
65
+ - [React](https://www.npmjs.com/package/react) - `v18.3` and above
66
+ - [React DOM](https://www.npmjs.com/package/react-dom) -`v18.3` and above
67
+
68
+ ### Installation
69
+
70
+ Install Webcore as a dependency by running one of the following command:
71
+
72
+ ```bash
73
+ # Using NPM
74
+ npm i webcoreui
75
+
76
+ # Using Yarn
77
+ yarn add webcoreui
78
+ ```
79
+
80
+ ### Setup
81
+
82
+ 1. Add the following to your `tsconfig.json` to include TypeScript types:
83
+
84
+ ```json
85
+ {
86
+ "include": ["webcoreui"]
87
+ }
88
+ ```
89
+
90
+ 2. Setup default styles and fonts by calling the following in your global SCSS file:
91
+
92
+ ```scss
93
+ @import 'webcoreui/styles';
94
+ @include Setup((
95
+ // Define paths for your fonts
96
+ fontRegular: '/fonts/Inter-Regular.woff2',
97
+ fontBold: '/fonts/Inter-Bold.woff2'
98
+ ));
99
+ ```
100
+
101
+ > [!TIP]
102
+ > You can download the fonts Webcore uses from the [`public/fonts`](https://github.com/Frontendland/webcoreui/tree/main/public/fonts) directory.
103
+
104
+ The `Setup` mixin can also accept the following options:
105
+
106
+
107
+ | Property | Default value | Purpose |
108
+ |-----------|---------------|---------|
109
+ | `includeResets` | `true` | Include reset styles. Set to `false` if you want to use your own CSS resets. |
110
+ | `includeHelperClasses` | `true` | Adds global helper classes for CSS. All global helper classes are defined [here](https://github.com/Frontendland/webcoreui/tree/main/src/scss/global). |
111
+
112
+ ### Using Components
113
+
114
+ Start using Webcore components in your code by importing them:
115
+
116
+ ```astro
117
+ ---
118
+ // Import the component relevant to your project
119
+ // How to import Astro components
120
+ import { Accordion } from 'webcoreui/astro'
121
+
122
+ // How to import Svelte components
123
+ import { Accordion } from 'webcoreui/svelte'
124
+
125
+ // How to import React components
126
+ import { Accordion } from 'webcoreui/react'
127
+ ---
128
+
129
+ <Accordion items={[{ ... }]} />
130
+ ```
131
+
132
+ ## Components
133
+
134
+ - [Accordion](https://github.com/Frontendland/webcoreui/tree/main/src/components/Accordion)
135
+ - [Button](https://github.com/Frontendland/webcoreui/tree/main/src/components/Button)
136
+ - [Card](https://github.com/Frontendland/webcoreui/tree/main/src/components/Card)
package/astro.js CHANGED
@@ -1,3 +1,7 @@
1
- import Accordion from './components/Accordion/Accordion.astro'
1
+ import AccordionComponent from './components/Accordion/Accordion.astro'
2
+ import ButtonComponent from './components/Button/Button.astro'
3
+ import CardComponent from './components/Card/Card.astro'
2
4
 
3
- export const Accordion = Accordion
5
+ export const Accordion = AccordionComponent
6
+ export const Button = ButtonComponent
7
+ export const Card = CardComponent
@@ -11,7 +11,15 @@ const {
11
11
  <ul data-id="accordion">
12
12
  {items.map(item => (
13
13
  <li>
14
- <div class="accordion-title">{item.title}</div>
14
+ <div class="accordion-title">
15
+ {item.title}
16
+ <img
17
+ src="/icons/arrow-down.svg"
18
+ alt="GitHub"
19
+ width={15}
20
+ height={15}
21
+ />
22
+ </div>
15
23
  <div class="accordion-wrapper">
16
24
  <div class="accordion-content">
17
25
  <Fragment set:html={item.content} />
@@ -22,6 +22,12 @@
22
22
  on:click={() => toggle(index)}
23
23
  >
24
24
  {item.title}
25
+ <img
26
+ src="/icons/arrow-down.svg"
27
+ alt="GitHub"
28
+ width={15}
29
+ height={15}
30
+ />
25
31
  </div>
26
32
  <div class="accordion-wrapper">
27
33
  <div class="accordion-content">
@@ -21,6 +21,12 @@ export const Accordion = ({ items }: AccordionProps) => {
21
21
  onClick={() => toggle(index)}
22
22
  >
23
23
  {item.title}
24
+ <img
25
+ src="/icons/arrow-down.svg"
26
+ alt="GitHub"
27
+ width={15}
28
+ height={15}
29
+ />
24
30
  </div>
25
31
  <div className="accordion-wrapper">
26
32
  <div className="accordion-content">
@@ -20,13 +20,27 @@ ul {
20
20
  }
21
21
 
22
22
  .accordion-title {
23
+ display: flex;
24
+ justify-content: space-between;
25
+ align-items: center;
23
26
  cursor: pointer;
24
27
 
25
- &.open + .accordion-wrapper {
26
- grid-template-rows: 1fr;
27
-
28
- .accordion-content {
29
- padding: 10px 0;
28
+ img {
29
+ @include Transition(transform);
30
+ filter: brightness(.7);
31
+ }
32
+
33
+ &.open {
34
+ img {
35
+ transform: rotate(180deg);
36
+ }
37
+
38
+ + .accordion-wrapper {
39
+ grid-template-rows: 1fr;
40
+
41
+ .accordion-content {
42
+ padding: 10px 0;
43
+ }
30
44
  }
31
45
  }
32
46
  }
@@ -40,7 +54,7 @@ ul {
40
54
  .accordion-content {
41
55
  @include Transition();
42
56
  overflow: hidden;
43
- color: #DDD;
57
+ color: #BBB;
44
58
  }
45
59
  }
46
60
  }
@@ -1,22 +1,28 @@
1
1
  ---
2
- interface Props {
3
- theme?: 'secondary' | 'tertiary'
4
- [key: string]: any
5
- }
2
+ import type { ButtonProps } from './button'
3
+
4
+ interface Props extends ButtonProps {}
6
5
 
7
6
  const {
8
7
  theme,
8
+ bold,
9
9
  href,
10
10
  ...rest
11
11
  } = Astro.props
12
+
13
+ const classes = [
14
+ 'w-button',
15
+ bold && 'bold',
16
+ theme
17
+ ].filter(Boolean).join(' ')
12
18
  ---
13
19
 
14
20
  {href ? (
15
- <a {...rest} href={href} class={theme || null}>
21
+ <a {...rest} href={href} class={classes || null}>
16
22
  <slot />
17
23
  </a>
18
24
  ) : (
19
- <button {...rest}>
25
+ <button {...rest} class={classes || null}>
20
26
  <slot />
21
27
  </button>
22
28
  )}
@@ -0,0 +1,29 @@
1
+ <script lang="ts">
2
+ import type { ButtonProps } from './button'
3
+
4
+ export let theme: ButtonProps['theme'] = null
5
+ export let bold: ButtonProps['bold'] = false
6
+ export let href: ButtonProps['href'] = ''
7
+ export let onClick: ButtonProps['onClick'] = () => {}
8
+
9
+ const classes = [
10
+ 'w-button',
11
+ bold && 'bold',
12
+ theme
13
+ ].filter(Boolean).join(' ')
14
+ </script>
15
+
16
+
17
+ {#if href}
18
+ <a {...$$restProps} href={href} class={classes || null}>
19
+ <slot />
20
+ </a>
21
+ {:else}
22
+ <button {...$$restProps} class={classes || null} on:click={onClick}>
23
+ <slot />
24
+ </button>
25
+ {/if}
26
+
27
+ <style lang="scss">
28
+ @import './button.scss';
29
+ </style>
@@ -0,0 +1,32 @@
1
+ import React from 'react'
2
+ import type { ButtonProps } from './button'
3
+ import './button.scss'
4
+
5
+ export const Button = ({
6
+ theme,
7
+ bold,
8
+ href,
9
+ children,
10
+ onClick,
11
+ ...rest
12
+ }: ButtonProps) => {
13
+ const classes = [
14
+ 'w-button',
15
+ bold && 'bold',
16
+ theme
17
+ ].filter(Boolean).join(' ')
18
+
19
+ if (href) {
20
+ return (
21
+ <a {...rest} href={href} className={classes || undefined}>
22
+ {children}
23
+ </a>
24
+ )
25
+ }
26
+
27
+ return (
28
+ <button {...rest} className={classes || undefined} onClick={onClick}>
29
+ {children}
30
+ </button>
31
+ )
32
+ }
@@ -1,21 +1,92 @@
1
1
  @import '../../scss/config.scss';
2
2
 
3
- a {
3
+ .w-button {
4
+ @include Transition();
4
5
  padding: 10px 15px;
5
6
  border-radius: 5px;
6
- color: #FFF;
7
7
  text-decoration: none;
8
8
  display: inline-flex;
9
9
  align-items: center;
10
10
  gap: 5px;
11
11
  font-size: 16px;
12
+ font-family: Regular;
13
+ cursor: pointer;
14
+ border: 0;
15
+ background: #FFF;
16
+ color: #252525;
12
17
 
18
+ &[disabled] {
19
+ cursor: no-drop;
20
+ background: #BBB;
21
+ }
22
+
23
+ &:hover {
24
+ background: #BBB;
25
+ }
26
+
13
27
  &.secondary {
14
- @include Transition(background);
15
28
  background: #252525;
29
+ color: #FFF;
30
+
31
+ &:hover {
32
+ background: #333;
33
+ }
34
+ }
35
+
36
+ &.outline {
37
+ background: #000;
38
+ color: #FFF;
39
+ box-shadow: inset 0px 0px 0px 1px #FFF;
40
+
41
+ &:hover {
42
+ color: #BBB;
43
+ box-shadow: inset 0px 0px 0px 1px #BBB;
44
+ }
45
+ }
46
+
47
+ &.flat {
48
+ background: #000;
49
+ color: #FFF;
16
50
 
17
51
  &:hover {
18
52
  background: #333;
19
53
  }
20
54
  }
55
+
56
+ &.info {
57
+ background: #0abde3;
58
+
59
+ &:hover {
60
+ background: #48dbfb;
61
+ }
62
+ }
63
+
64
+ &.success {
65
+ background: #10ac84;
66
+
67
+ &:hover {
68
+ background: #1dd1a1;
69
+ }
70
+ }
71
+
72
+ &.warning {
73
+ background: #ff9f43;
74
+
75
+ &:hover {
76
+ background: #f7aa61;
77
+ }
78
+ }
79
+
80
+ &.alert {
81
+ background: #e73f40;
82
+ color: #fff;
83
+
84
+ &:hover {
85
+ background: #ee5253;
86
+ }
87
+ }
88
+
89
+ &.bold {
90
+ font-family: Bold;
91
+ }
21
92
  }
@@ -0,0 +1,14 @@
1
+ export type ButtonProps = {
2
+ theme?: 'secondary'
3
+ | 'outline'
4
+ | 'flat'
5
+ | 'info'
6
+ | 'success'
7
+ | 'warning'
8
+ | 'alert'
9
+ | null
10
+ bold?: boolean
11
+ href?: string
12
+ onClick?: () => any
13
+ [key: string]: any
14
+ }
@@ -3,6 +3,8 @@ interface Props {
3
3
  element?: string
4
4
  title?: string
5
5
  compact?: boolean
6
+ className?: string
7
+ secondary?: boolean
6
8
  [key: string]: any
7
9
  }
8
10
 
@@ -10,12 +12,20 @@ const {
10
12
  element = 'section',
11
13
  title,
12
14
  titleTag = 'span',
13
- compact = true,
15
+ compact,
16
+ className,
17
+ secondary,
14
18
  ...rest
15
19
  } = Astro.props
16
20
 
21
+ const classes = [
22
+ className,
23
+ secondary && 'secondary',
24
+ 'card'
25
+ ].filter(Boolean).join(' ')
26
+
17
27
  const props = {
18
- class: 'card'
28
+ class: classes
19
29
  }
20
30
 
21
31
  const Component = element
@@ -27,7 +37,7 @@ const Title = titleTag
27
37
  <Title class="card-title">{title}</Title>
28
38
  )}
29
39
  <div class="card-body" class:list={[compact && 'compact']}>
30
- {compact ? (
40
+ {compact && !secondary ? (
31
41
  <div class="card-wrapper"><slot /></div>
32
42
  ) : (
33
43
  <slot />
@@ -1,6 +1,16 @@
1
1
  .card {
2
2
  border: 1px solid #252525;
3
3
  border-radius: 5px;
4
+ display: flex;
5
+ flex-direction: column;
6
+
7
+ &.secondary {
8
+ background: #111;
9
+
10
+ .card-title {
11
+ background: #000;
12
+ }
13
+ }
4
14
 
5
15
  .card-title {
6
16
  padding: 20px;
@@ -11,6 +21,7 @@
11
21
 
12
22
  .card-body {
13
23
  padding: 20px;
24
+ height: 100%;
14
25
 
15
26
  &.compact {
16
27
  background: #111;
@@ -20,5 +31,6 @@
20
31
  .card-wrapper {
21
32
  background: #000;
22
33
  padding: 40px;
34
+ height: 100%;
23
35
  }
24
36
  }
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "webcoreui",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "scripts": {
6
6
  "dev": "astro dev",
7
7
  "build": "astro check && astro build",
8
8
  "build:package": "node scripts/build.js",
9
- "publish": "cd dist && np",
10
9
  "test": "echo \"Error: no test specified\""
11
10
  },
12
11
  "dependencies": {
@@ -28,15 +27,17 @@
28
27
  "./config": "./scss/config.scss"
29
28
  },
30
29
  "files": [
31
- "public",
32
30
  "components",
31
+ "public",
33
32
  "scss",
34
33
  "astro.d.ts",
35
34
  "astro.js",
36
35
  "svelte.d.ts",
37
36
  "svelte.js",
38
37
  "react.d.ts",
39
- "react.js"
38
+ "react.js",
39
+ "README.md",
40
+ "LICENSE"
40
41
  ],
41
42
  "license": "MIT",
42
43
  "description": "UI component and template library for Astro, Svelte, and React apps styled with Sass.",
@@ -56,7 +57,7 @@
56
57
  "homepage": "https://webcoreui.dev",
57
58
  "repository": {
58
59
  "type": "git",
59
- "url": "https://github.com/Frontendland/webcoreui"
60
+ "url": "git+https://github.com/Frontendland/webcoreui.git"
60
61
  },
61
62
  "bugs": {
62
63
  "url": "https://github.com/Frontendland/webcoreui/issues"
@@ -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="M0.360618 6.42142C0.864272 5.88419 1.70806 5.85699 2.24526 6.36062L12 15.5057L21.7547 6.36062C22.292 5.85699 23.1358 5.88419 23.6395 6.42142C24.143 6.95865 24.1158 7.80243 23.5787 8.30606L12.9119 18.3062C12.3991 18.787 11.601 18.787 11.0881 18.3062L0.421418 8.30606C-0.11581 7.80243 -0.143009 6.95865 0.360618 6.42142Z" fill="white" />
3
+ </svg>
package/react.js CHANGED
@@ -1,3 +1,7 @@
1
- import { Accordion } from './components/Accordion/Accordion.tsx'
1
+ import { Accordion as AccordionComponent } from './components/Accordion/Accordion.tsx'
2
+ import { Button as ButtonComponent } from './components/Button/Button.tsx'
3
+ import { Card as CardComponent } from './components/Card/Card.tsx'
2
4
 
3
- export const Accordion = Accordion
5
+ export const Accordion = AccordionComponent
6
+ export const Button = ButtonComponent
7
+ export const Card = CardComponent
@@ -0,0 +1,11 @@
1
+ @import '../config';
2
+
3
+ @mixin Elements() {
4
+ code {
5
+ display: inline-block;
6
+ padding: 2px 10px;
7
+ border-radius: 5px;
8
+ border: 1px solid #252525;
9
+ font-size: 14px;
10
+ }
11
+ }
package/scss/global.scss CHANGED
@@ -1 +1,2 @@
1
+ @import './global/elements.scss';
1
2
  @import './global/utility.scss';
package/scss/setup.scss CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  $config: (
4
4
  includeResets: true,
5
- includeHelperClasses: true
5
+ includeHelperClasses: true,
6
+ includeElementStyles: true
6
7
  );
7
8
 
8
9
  @function config($key) {
@@ -19,4 +20,8 @@ $config: (
19
20
  @if (config('includeHelperClasses')) {
20
21
  @include Utility();
21
22
  }
23
+
24
+ @if (config('includeElementStyles')) {
25
+ @include Elements();
26
+ }
22
27
  }
package/svelte.js CHANGED
@@ -1,3 +1,7 @@
1
- import Accordion from './components/Accordion/Accordion.svelte'
1
+ import AccordionComponent from './components/Accordion/Accordion.svelte'
2
+ import ButtonComponent from './components/Button/Button.svelte'
3
+ import CardComponent from './components/Card/Card.svelte'
2
4
 
3
- export const Accordion = Accordion
5
+ export const Accordion = AccordionComponent
6
+ export const Button = ButtonComponent
7
+ export const Card = CardComponent