lism-css 0.9.0 → 0.9.2
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/README.md +41 -19
- package/dist/components/Dummy/index.js +5 -5
- package/dist/components/LinkBox/index.js +4 -4
- package/dist/components/Lism/Lism.d.ts +2 -4
- package/dist/components/Lism/index.js +5 -5
- package/dist/components/atomic/Icon/getProps.d.ts +1 -1
- package/dist/components/atomic/Icon/getProps.js +40 -41
- package/package.json +1 -1
- package/packages/astro/Dummy/Dummy.astro +4 -4
- package/packages/astro/HTML/_index_memo.js +3 -3
- package/packages/astro/HTML/a.astro +1 -1
- package/packages/astro/HTML/button.astro +1 -1
- package/packages/astro/HTML/div.astro +1 -1
- package/packages/astro/HTML/h.astro +1 -1
- package/packages/astro/HTML/img.astro +1 -1
- package/packages/astro/HTML/li.astro +1 -1
- package/packages/astro/HTML/ol.astro +1 -1
- package/packages/astro/HTML/p.astro +1 -1
- package/packages/astro/HTML/span.astro +1 -1
- package/packages/astro/HTML/ul.astro +1 -1
- package/packages/astro/LinkBox/LinkBox.astro +1 -1
- package/packages/astro/Lism/Lism.astro +2 -2
- package/packages/astro/Media/Media.astro +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
# lism-css
|
|
2
|
+
|
|
3
|
+
A lightweight, layout-first CSS framework for websites.
|
|
4
|
+
Provides CSS utilities, design tokens, and React / Astro layout components.
|
|
2
5
|
|
|
3
|
-
For details, see [
|
|
6
|
+
For details, see [Documentation](https://lism-css.com/).
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
## Installation
|
|
6
9
|
|
|
7
10
|
```bash
|
|
8
11
|
npm i lism-css
|
|
@@ -14,39 +17,58 @@ or
|
|
|
14
17
|
pnpm add lism-css
|
|
15
18
|
```
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
## Setup
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
Import CSS as a global style.
|
|
20
23
|
|
|
21
24
|
```js
|
|
22
25
|
import 'lism-css/main.css';
|
|
23
26
|
```
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
For Next.js, load it in `layout.js` (App Router) or `_app.js` (Pages Router).
|
|
26
29
|
|
|
27
|
-
For HTML sites, you can
|
|
30
|
+
For HTML sites, you can load CSS via CDN:
|
|
28
31
|
|
|
29
32
|
```html
|
|
30
33
|
<link href="https://cdn.jsdelivr.net/npm/lism-css/dist/css/main.css" rel="stylesheet" />
|
|
31
34
|
```
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### React
|
|
34
39
|
|
|
35
40
|
```jsx
|
|
36
|
-
import { Box,
|
|
41
|
+
import { Box, Flex, Stack, HTML } from 'lism-css/react';
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
<Box p=
|
|
40
|
-
|
|
41
|
-
</Box>
|
|
42
|
-
|
|
43
|
+
<Stack g="20">
|
|
44
|
+
<Box p="20" bgc="base-2">
|
|
45
|
+
<HTML.p fz="l">Lorem ipsum text...</HTML.p>
|
|
46
|
+
</Box>
|
|
47
|
+
</Stack>
|
|
43
48
|
```
|
|
44
49
|
|
|
50
|
+
### Astro
|
|
51
|
+
|
|
52
|
+
```astro
|
|
53
|
+
---
|
|
54
|
+
import { Box, Flex, Stack, HTML } from 'lism-css/astro';
|
|
45
55
|
---
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
<Stack g="20">
|
|
58
|
+
<Box p="20" bgc="base-2">
|
|
59
|
+
<HTML.p fz="l">Lorem ipsum text...</HTML.p>
|
|
60
|
+
</Box>
|
|
61
|
+
</Stack>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## UI Components
|
|
65
|
+
|
|
66
|
+
For interactive UI components (Accordion, Modal, Tabs, etc.), see [@lism-css/ui](https://www.npmjs.com/package/@lism-css/ui).
|
|
67
|
+
|
|
68
|
+
## Credits
|
|
69
|
+
|
|
70
|
+
- [Phosphor Icons](https://phosphoricons.com/) — MIT License ([source](https://github.com/phosphor-icons))
|
|
71
|
+
|
|
72
|
+
## License
|
|
48
73
|
|
|
49
|
-
|
|
50
|
-
Website: https://phosphoricons.com/
|
|
51
|
-
Source: https://github.com/phosphor-icons
|
|
52
|
-
License: MIT License, https://opensource.org/licenses/MIT
|
|
74
|
+
MIT
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import g from "./getContent.js";
|
|
3
3
|
import e from "../Lism/index.js";
|
|
4
|
-
function d({ pre: i = "", length:
|
|
5
|
-
const m = t.as ||
|
|
4
|
+
function d({ pre: i = "", length: o = "m", lang: r = "en", offset: s = 0, ...t }) {
|
|
5
|
+
const m = t.as || "p";
|
|
6
6
|
if (m === "img")
|
|
7
7
|
return /* @__PURE__ */ n(e, { as: "img", src: "https://cdn.lism-css.com/dummy-image.jpg", width: 600, height: 400, alt: "", ...t });
|
|
8
|
-
const
|
|
9
|
-
return /* @__PURE__ */ n(e, { ...t, dangerouslySetInnerHTML: { __html:
|
|
8
|
+
const a = g({ tag: m, pre: i, lang: r, length: o, offset: s });
|
|
9
|
+
return /* @__PURE__ */ n(e, { ...t, dangerouslySetInnerHTML: { __html: a } });
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
12
|
d as default
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
function
|
|
2
|
+
import s from "../Lism/index.js";
|
|
3
|
+
function n({ children: t, ...r }) {
|
|
4
4
|
const o = !!r.href ? "a" : "div";
|
|
5
|
-
return /* @__PURE__ */ i(
|
|
5
|
+
return /* @__PURE__ */ i(s, { isLinkBox: !0, as: o, ...r, children: t });
|
|
6
6
|
}
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
n as default
|
|
9
9
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ElementType, ReactNode
|
|
1
|
+
import { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
|
|
2
2
|
import { LismProps } from '../../lib/getLismProps';
|
|
3
3
|
import { LayoutSpecificProps } from '../../lib/types/LayoutProps';
|
|
4
4
|
/** HTML 要素 Props と共通オプションの基底型 */
|
|
5
5
|
type LismBaseProps<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, keyof LismProps> & {
|
|
6
6
|
/** レンダリングするコンポーネントまたは要素 */
|
|
7
7
|
as?: T;
|
|
8
|
-
/** レンダリングするHTML要素のタグ名(文字列のみ)*/
|
|
9
|
-
tag?: keyof JSX.IntrinsicElements;
|
|
10
8
|
/** 子要素 */
|
|
11
9
|
children?: ReactNode;
|
|
12
10
|
/** getLismProps を経由せずに直接渡す追加の props */
|
|
@@ -27,5 +25,5 @@ export type LayoutComponentProps<T extends ElementType = 'div', L = object> = Om
|
|
|
27
25
|
/**
|
|
28
26
|
* Lism Propsを処理できるだけのコンポーネント
|
|
29
27
|
*/
|
|
30
|
-
export default function Lism<T extends ElementType = 'div'>({ children, as,
|
|
28
|
+
export default function Lism<T extends ElementType = 'div'>({ children, as, exProps, ...props }: LismComponentProps<T>): import("react").JSX.Element;
|
|
31
29
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import e from "../../lib/getLismProps.js";
|
|
3
|
+
function f({ children: o, as: t, exProps: m, ...n }) {
|
|
4
|
+
return /* @__PURE__ */ r(t || "div", { ...e(n), ...m, children: o });
|
|
5
5
|
}
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
f as default
|
|
8
8
|
};
|
|
@@ -12,7 +12,7 @@ type IconOwnProps = {
|
|
|
12
12
|
exProps?: Record<string, unknown>;
|
|
13
13
|
};
|
|
14
14
|
export type IconProps = LismComponentProps & TransformStyleProps & IconOwnProps;
|
|
15
|
-
export default function getProps({ lismClass, as,
|
|
15
|
+
export default function getProps({ lismClass, as, icon, label, exProps, ..._props }: IconProps): {
|
|
16
16
|
Component: ElementType | "_SVG_";
|
|
17
17
|
lismProps: {
|
|
18
18
|
[key: string]: unknown;
|
|
@@ -1,56 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
const [,
|
|
8
|
-
let
|
|
9
|
-
for (; (
|
|
10
|
-
const [,
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const [
|
|
15
|
-
|
|
16
|
-
}),
|
|
1
|
+
import S from "./presets.js";
|
|
2
|
+
import h from "../../../lib/helper/atts.js";
|
|
3
|
+
import C from "../../setMaybeTransformStyles.js";
|
|
4
|
+
function b(g) {
|
|
5
|
+
const f = {}, s = g.match(/<svg([^>]*?)>([\s\S]*?)<\/svg>/i);
|
|
6
|
+
if (s) {
|
|
7
|
+
const [, o, t] = s, u = /([\w-]+)=["']([^"']*)["']/g;
|
|
8
|
+
let e;
|
|
9
|
+
for (; (e = u.exec(o)) !== null; ) {
|
|
10
|
+
const [, r, m] = e;
|
|
11
|
+
if (r === "style") {
|
|
12
|
+
const c = {};
|
|
13
|
+
m.split(";").forEach((l) => {
|
|
14
|
+
const [i, n] = l.split(":").map((a) => a.trim());
|
|
15
|
+
i && n && (c[i] = n);
|
|
16
|
+
}), f[r] = c;
|
|
17
17
|
} else
|
|
18
|
-
|
|
18
|
+
f[r] = m;
|
|
19
19
|
}
|
|
20
|
-
return { svgProps:
|
|
20
|
+
return { svgProps: f, svgContent: t };
|
|
21
21
|
}
|
|
22
22
|
return {};
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
let
|
|
24
|
+
function V({ lismClass: g, as: f, icon: s, label: o, exProps: t = {}, ...u }) {
|
|
25
|
+
let e = f || "span", r = "";
|
|
26
26
|
const {
|
|
27
|
-
style:
|
|
28
|
-
className:
|
|
27
|
+
style: m = {},
|
|
28
|
+
className: c = "",
|
|
29
29
|
...l
|
|
30
|
-
} =
|
|
31
|
-
let i =
|
|
30
|
+
} = C(u);
|
|
31
|
+
let i = m, n = c;
|
|
32
32
|
if (l.viewBox)
|
|
33
|
-
|
|
33
|
+
e = "svg", l.width || (t.width = "1em"), l.height || (t.height = "1em");
|
|
34
34
|
else if (l.src)
|
|
35
|
-
|
|
36
|
-
else if (
|
|
37
|
-
if (typeof
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
const { svgProps:
|
|
41
|
-
|
|
35
|
+
e = "img";
|
|
36
|
+
else if (s)
|
|
37
|
+
if (typeof s == "string")
|
|
38
|
+
if (s.startsWith("<svg")) {
|
|
39
|
+
e = "_SVG_";
|
|
40
|
+
const { svgProps: a = {}, svgContent: v = "" } = b(s), { class: y, style: p, ..._ } = a;
|
|
41
|
+
n = h(n, y), i = { ...i, ...p }, t = { ...t, ..._, fill: "currentColor" }, r = v;
|
|
42
42
|
} else {
|
|
43
|
-
const
|
|
44
|
-
|
|
43
|
+
const a = S[s] || null;
|
|
44
|
+
a != null && (e = "_SVG_", t = { ...t, ...a });
|
|
45
45
|
}
|
|
46
|
-
else if (typeof
|
|
47
|
-
const { as:
|
|
48
|
-
|
|
46
|
+
else if (typeof s == "object" && s.as) {
|
|
47
|
+
const { as: a, ...v } = s;
|
|
48
|
+
e = a, t = { ...t, ...v };
|
|
49
49
|
} else
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return m ? (t["aria-label"] = m, t.role = "img") : t["aria-hidden"] = "true", l.lismClass = y(u, "a--icon", f), l.style = { ...i }, { Component: s, lismProps: l, exProps: t, content: n };
|
|
50
|
+
e = s;
|
|
51
|
+
return o ? (t["aria-label"] = o, t.role = "img") : t["aria-hidden"] = "true", l.lismClass = h(g, "a--icon", n), l.style = { ...i }, { Component: e, lismProps: l, exProps: t, content: r };
|
|
53
52
|
}
|
|
54
53
|
export {
|
|
55
|
-
|
|
54
|
+
V as default
|
|
56
55
|
};
|
package/package.json
CHANGED
|
@@ -5,9 +5,9 @@ import getContent from '../../../dist/components/Dummy/getContent';
|
|
|
5
5
|
|
|
6
6
|
// Propsの定義
|
|
7
7
|
interface Props extends LismProps {}
|
|
8
|
-
const {
|
|
9
|
-
const content = getContent({ tag, pre, lang, length, offset });
|
|
8
|
+
const { as: tagName = 'p', pre = '', length = 'm', lang = 'en', offset = 0, ...props } = Astro.props || {};
|
|
9
|
+
const content = getContent({ tag: tagName, pre, lang, length, offset });
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
{
|
|
13
|
-
{
|
|
12
|
+
{tagName === 'img' && <Lism as='img' src='https://cdn.lism-css.com/dummy-image.jpg' width='600' height='400' alt='' {...props} />}
|
|
13
|
+
{tagName !== 'img' && <Lism as={tagName} {...props} set:html={content} />}
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
import { createComponent, renderComponent } from 'astro/runtime/server/index.js';
|
|
4
4
|
import Lism from '../Lism/Lism.astro';
|
|
5
5
|
|
|
6
|
-
// <Lism
|
|
6
|
+
// <Lism as="*"> の薄いラッパーを動的に生成するユーティリティ
|
|
7
7
|
const createHTMLComponent = (tag, baseProps = {}) =>
|
|
8
8
|
createComponent((result, props = {}, slots = {}) => {
|
|
9
|
-
return renderComponent(result, 'Lism', Lism, { tag, ...baseProps, ...props }, slots);
|
|
9
|
+
return renderComponent(result, 'Lism', Lism, { as: tag, ...baseProps, ...props }, slots);
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
// 見出しだけ lv でタグ名を変える
|
|
13
13
|
const createHeadingComponent = () =>
|
|
14
14
|
createComponent((result, props = {}, slots = {}) => {
|
|
15
15
|
const { lv = '1', ...rest } = props;
|
|
16
|
-
return renderComponent(result, 'Lism', Lism, {
|
|
16
|
+
return renderComponent(result, 'Lism', Lism, { as: `h${lv}`, ...rest }, slots);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
// よく使うタグをまとめてラップ
|
|
@@ -5,8 +5,8 @@ import getLismProps from '../../../dist/lib/getLismProps';
|
|
|
5
5
|
// Propsの定義
|
|
6
6
|
interface Props extends LismProps {}
|
|
7
7
|
|
|
8
|
-
const { as,
|
|
9
|
-
const JSX = as ||
|
|
8
|
+
const { as, exProps, ...props } = Astro.props || {};
|
|
9
|
+
const JSX = as || 'div';
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
<JSX {...getLismProps(props)} {...exProps}>
|
|
@@ -3,9 +3,9 @@ import getLismProps from '../../../dist/lib/getLismProps';
|
|
|
3
3
|
import getMediaProps from '../../../dist/components/atomic/Media/getProps';
|
|
4
4
|
import { Image } from 'astro:assets';
|
|
5
5
|
|
|
6
|
-
const { as, exProps,
|
|
6
|
+
const { as, exProps, ...props } = Astro.props || {};
|
|
7
7
|
|
|
8
|
-
let JSX = as ||
|
|
8
|
+
let JSX = as || 'img';
|
|
9
9
|
if (JSX === 'AstroImage') {
|
|
10
10
|
JSX = Image;
|
|
11
11
|
}
|