lapikit 0.0.2 → 0.0.3

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.
@@ -6,6 +6,7 @@ import path from 'path';
6
6
  import { ansi, sendConsole } from './ansi.js';
7
7
  import { minify } from './minify.js';
8
8
  import { colors } from './themes.js';
9
+ import { devices } from './devices.js';
9
10
  const __filename = fileURLToPath(import.meta.url);
10
11
  const __dirname = dirname(__filename);
11
12
  const __components = path.resolve('src/components');
@@ -24,8 +25,10 @@ export const processCSS = async (minified, normalize) => {
24
25
  if (normalize)
25
26
  styles += `${_normalize}\n`;
26
27
  const colorScheme = colors();
28
+ const deviceDisplay = devices();
27
29
  styles += `${colorScheme.root}\n`;
28
30
  styles += `${colorScheme.className}\n`;
31
+ styles += `${deviceDisplay}\n`;
29
32
  if (fs.existsSync(__components) && fs.statSync(__components).isDirectory()) {
30
33
  const tresholds = {
31
34
  _default: '',
@@ -0,0 +1 @@
1
+ export declare const devices: () => string;
@@ -0,0 +1,43 @@
1
+ const breakpoints = {
2
+ mobileBreakpoint: 'sm',
3
+ tabletBreakpoint: 'md',
4
+ laptopBreakpoint: 'xl',
5
+ thresholds: {
6
+ none: 0, // 0px
7
+ xs: '28rem', //448px
8
+ sm: '40rem', //640px
9
+ md: '48rem', //768px
10
+ lg: '64rem', //1024px
11
+ xl: '80rem', //1280px
12
+ '2xl': '96rem', //1536px
13
+ '3xl': '112rem' //1792px
14
+ }
15
+ };
16
+ export const devices = () => {
17
+ let css = ``;
18
+ const list = {
19
+ mobile: breakpoints.mobileBreakpoint,
20
+ tablet: breakpoints.tabletBreakpoint,
21
+ laptop: breakpoints.laptopBreakpoint
22
+ };
23
+ for (const [key, value] of Object.entries(list)) {
24
+ const breakpointValue = breakpoints.thresholds[value];
25
+ const breakpointValueMax = key !== 'laptop'
26
+ ? breakpoints.thresholds[key === 'mobile' ? list.tablet : key == 'tablet' ? list.laptop : '']
27
+ : undefined;
28
+ css += `.device-${key}, .only-on-${key} {\n`;
29
+ css += `display: none;\n`;
30
+ css += `}\n`;
31
+ css += `@media screen and (min-width: ${typeof breakpointValue === 'number' ? breakpointValue + 'px' : breakpointValue}) {\n`;
32
+ css += `.device-${key} {\n`;
33
+ css += `display: inherit !important;\n`;
34
+ css += `}\n`;
35
+ css += `}\n`;
36
+ css += `@media screen and (min-width: ${typeof breakpointValue === 'number' ? breakpointValue + 'px' : breakpointValue}) ${breakpointValueMax ? `and (max-width: ${typeof breakpointValueMax === 'number' ? breakpointValueMax + 'px' : breakpointValueMax})` : ''}{\n`;
37
+ css += `.only-on-${key} {\n`;
38
+ css += `display: inherit !important;\n`;
39
+ css += `}\n`;
40
+ css += `}\n`;
41
+ }
42
+ return css;
43
+ };
@@ -8,10 +8,10 @@ export async function lapikit(options = {}) {
8
8
  console.log(ansi.bold.blue('Vite plugin loaded'), options);
9
9
  const config = await importer();
10
10
  await processCSS(options.minify, options.normalize);
11
- // console.log('config', config);
11
+ console.log('config', config);
12
12
  },
13
13
  async configureServer(server) {
14
- // console.log(ansi.inverse.red('Vite server configured'), server);
14
+ console.log(ansi.inverse.red('Vite server configured'), server);
15
15
  }
16
16
  };
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,14 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Nycolaide/lapikit.git",
10
+ "directory": "packages/lapikit"
11
+ },
4
12
  "scripts": {
5
13
  "dev": "vite dev",
6
14
  "build": "vite build && npm run prepack",
@@ -14,9 +22,6 @@
14
22
  "test:unit": "vitest",
15
23
  "test": "npm run test:unit -- --run"
16
24
  },
17
- "publishConfig": {
18
- "access": "public"
19
- },
20
25
  "files": [
21
26
  "dist",
22
27
  "!dist/**/*.test.*",