Skip to content

Commit 78a792d

Browse files
authored
Merge pull request #7 from ryu-man/0.2.0
0.2.0
2 parents 358f9a7 + 7e94f4b commit 78a792d

413 files changed

Lines changed: 72087 additions & 13084 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.storybook/main.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
stories: [
5+
'../stories/**/*.stories.mdx',
6+
'../stories/**/*.stories.@(js|jsx|ts|tsx|svelte)'
7+
],
8+
addons: [
9+
'@storybook/addon-links',
10+
'@storybook/addon-essentials',
11+
'@storybook/addon-svelte-csf'
12+
],
13+
core: {
14+
builder: 'webpack5'
15+
},
16+
webpackFinal: async (config, { configType }) => {
17+
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
18+
// You can change the configuration based on that.
19+
// 'PRODUCTION' is used when building the static version of storybook.
20+
21+
config.resolve = {
22+
...config.resolve,
23+
// see below for an explanation
24+
alias: {
25+
svelte: path.resolve('node_modules', 'svelte')
26+
},
27+
extensions: ['.mjs', '.js', '.svelte'],
28+
mainFields: ['svelte', 'browser', 'module', 'main']
29+
}
30+
31+
// Return the altered config
32+
return config
33+
}
34+
}

.storybook/manager.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// .storybook/manager.js
2+
3+
import { addons } from '@storybook/addons';
4+
5+
addons.setConfig({
6+
isFullscreen: false,
7+
showNav: true,
8+
showPanel: true,
9+
panelPosition: 'right',
10+
enableShortcuts: true,
11+
isToolshown: true,
12+
theme: undefined,
13+
selectedPanel: undefined,
14+
initialActive: 'sidebar',
15+
sidebar: {
16+
showRoots: false,
17+
collapsedRoots: ['other'],
18+
},
19+
toolbar: {
20+
title: { hidden: false, },
21+
zoom: { hidden: false, },
22+
eject: { hidden: false, },
23+
copy: { hidden: false, },
24+
fullscreen: { hidden: false, },
25+
},
26+
});

.storybook/preview.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const parameters = {
2+
actions: { argTypesRegex: '^on[A-Z].*' },
3+
controls: {
4+
// expanded: true,
5+
matchers: {
6+
color: /(background|color)$/i,
7+
date: /Date$/
8+
}
9+
}
10+
}

README.md

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,47 +79,75 @@ Add svantic and modify `src/App.svelte` file in the following way
7979
import { Button } from 'svantic'
8080
</script>
8181

82-
<button>Hello world</button>
82+
<Button>Hello world</button>
8383
```
8484

8585
```html
8686
<script>
8787
// import modules
88-
import { Dropdown, Icon } from 'svantic';
88+
import { Dropdown, initDropdown, controllable, Icon } from 'svantic';
89+
90+
// call this function if you want to use Module.SubModule syntax, ex: Dropdown.Item
91+
initDropdown()
92+
93+
const dropdownController = controllable(controller=>{
94+
// called when the module is mounted and ready
95+
// access the controller and manupilate dropdown
96+
})
8997
90-
</script>
9198
92-
// Every module have two props: onMount{function} and setting{object}
99+
</script>
93100

94-
// onMount function: allows control module behaviors
101+
// onMount: allows control module behaviors
95102
// settings: pass module settings
96-
<Dropdown selection onMount={(controller) => {}} settings={{}}>
103+
<Dropdown
104+
bind:this={$dropdownController}
105+
onMount={(domElem) => {}}
106+
settings={{}}
107+
selection >
97108
<Icon name="caret down" />
98-
<Dropdown.text>Select language</Dropdown.text>
99-
<Dropdown.menu>
100-
<Dropdown.item>English</Dropdown.item>
101-
<Dropdown.item>Arabic</Dropdown.item>
102-
<Dropdown.item>Spanish</Dropdown.item>
103-
<Dropdown.item>German</Dropdown.item>
104-
</Dropdown.menu>
109+
<Dropdown.Text>Select language</Dropdown.Text>
110+
<Dropdown.Menu>
111+
<Dropdown.Item>English</Dropdown.Item>
112+
<Dropdown.Item>Arabic</Dropdown.Item>
113+
<Dropdown.Item>Spanish</Dropdown.Item>
114+
<Dropdown.Item>German</Dropdown.Item>
115+
</Dropdown.Menu>
105116
</Dropdown>
106117
```
107118

108-
...then start [Rollup](https://rollupjs.org/)
119+
Another way to use Module.SubModule syntax
109120

110-
```bash
111-
npm run dev
121+
```html
122+
<script>
123+
import { Icon } from 'svantic'
124+
import * as Dropdown from 'svantic/modules/dropdown';
125+
</script>
126+
127+
<Dropdown.default selection >
128+
<Icon name="caret down" />
129+
<Dropdown.Text>Select language</Dropdown.Text>
130+
<Dropdown.Menu>
131+
<Dropdown.Item>English</Dropdown.Item>
132+
<Dropdown.Item>Arabic</Dropdown.Item>
133+
<Dropdown.Item>Spanish</Dropdown.Item>
134+
<Dropdown.Item>German</Dropdown.Item>
135+
</Dropdown.Menu>
136+
</Dropdown.default>
112137
```
138+
**Breaking Change**
139+
140+
- onMount prop: allows acces to the top level dom elem instead of module controller
141+
142+
- module controller: to controll a module you use bind:this={varname} on the component to save an instance of its controller
113143

114-
Navigate to [localhost:5000](http://localhost:5000)
144+
- controllable store is a reactive store that allows subscribtion to a module and execute a callback
115145

116146
## Development
117147

118148
1. Clone this repo: `git clone https://github.com/ryu-man/svantic.git`
119149
2. Install dependencies: `npm i`
120150
3. Start building fomantic: `npm run build:fomantic`
121-
4. Start the automated build: `npm run build`
122-
5. Open url that console prints in your browser
123151

124152
## License
125153

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" href="/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Svelte + Vite App</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.js"></script>
12+
</body>
13+
</html>

jsconfig.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "node",
4+
"target": "esnext",
5+
"module": "esnext",
6+
/**
7+
* svelte-preprocess cannot figure out whether you have
8+
* a value or a type, so tell TypeScript to enforce using
9+
* `import type` instead of `import` for Types.
10+
*/
11+
"importsNotUsedAsValues": "error",
12+
"isolatedModules": true,
13+
"resolveJsonModule": true,
14+
/**
15+
* To have warnings / errors of the Svelte compiler at the
16+
* correct position, enable source maps by default.
17+
*/
18+
"sourceMap": true,
19+
"esModuleInterop": true,
20+
"skipLibCheck": true,
21+
"forceConsistentCasingInFileNames": true,
22+
"baseUrl": ".",
23+
/**
24+
* Typecheck JS in `.svelte` and `.js` files by default.
25+
* Disable this if you'd like to use dynamic types.
26+
*/
27+
"checkJs": true
28+
},
29+
/**
30+
* Use global.d.ts instead of compilerOptions.types
31+
* to avoid limiting type declarations.
32+
*/
33+
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
34+
}

0 commit comments

Comments
 (0)