Skip to content

Commit 0f759bf

Browse files
wip
1 parent f318e1a commit 0f759bf

Some content is hidden

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

64 files changed

+639
-26
lines changed

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"./css/*": "./src/css/*.css",
1414
"./scss/*": "./src/scss/*.scss",
1515
"./components/*": "./src/components/*/index.js",
16-
"./hooks/*": "./src/hooks/*.js",
1716
"./icons/*": "./src/icons/*.svg"
1817
},
1918
"publishConfig": {
@@ -27,27 +26,33 @@
2726
"format:scss": "stylelint ./src/**/*.scss --fix",
2827
"lint:css": "stylelint ./src/**/*.css",
2928
"format:css": "stylelint ./src/**/*.css --fix",
30-
"link:local": "yarn link",
31-
"unlink:local": "yarn unlink",
32-
"_link:local": "yarn link && cd node_modules/react && yarn link && cd ../react-dom && yarn link",
33-
"_unlink:local": "yarn unlink && cd node_modules/react && yarn unlink && cd ../react-dom && yarn unlink",
29+
"_link:local": "yarn link",
30+
"_unlink:local": "yarn unlink",
31+
"link:local": "yarn link && cd node_modules/react && yarn link && cd ../react-dom && yarn link",
32+
"unlink:local": "yarn unlink && cd node_modules/react && yarn unlink && cd ../react-dom && yarn unlink",
3433
"compile-sass": "node ./sass.js"
3534
},
36-
"_peerDependencies": {
35+
"peerDependencies": {
3736
"react": ">=19",
3837
"react-dom": ">=19"
3938
},
4039
"devDependencies": {
4140
"express": "^4.18.2",
4241
"path": "^0.12.7",
4342
"prettier": "^3.5.3",
43+
"react": "19.1.0",
44+
"react-dom": "19.1.0",
4445
"sass": "^1.83.4",
4546
"stylelint": "^16.13.2",
4647
"stylelint-config-css-modules": "^4.4.0",
4748
"stylelint-config-standard": "^37.0.0",
4849
"stylelint-prettier": "^5.0.2"
4950
},
5051
"dependencies": {
51-
"startijenn-rem": "^1.1.1"
52+
"camelize-object-keys": "^3.0.0",
53+
"clsx": "^2.1.1",
54+
"query-string": "^9.1.2",
55+
"startijenn-rem": "^1.1.1",
56+
"string-humanize": "^1.0.1"
5257
}
5358
}

src/_components/map-control-button/index.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/_components/map-control-button/index.module.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/components/button/index.js

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import { memo } from "react"
2+
import clsx from "clsx"
3+
// import { convert } from "startijenn-rem"
4+
import emify from "../../postcss/fn.emify"
5+
6+
import IconLoading from "../../icons/loading.svg"
7+
import style from "./index.module.css"
8+
9+
const ButtonMemoized = memo(function Button({
10+
children,
11+
text = ``,
12+
tag = `button`,
13+
type = `button`,
14+
href = undefined, // ``
15+
className = ``,
16+
loading = false,
17+
Icon = null,
18+
IconExtra = null,
19+
iconSrc,
20+
badge = ``,
21+
NextLink,
22+
// appearance
23+
fontSize = ``,
24+
color = ``,
25+
borderColor = ``,
26+
backgroundColor = ``,
27+
boxShadow = ``,
28+
align = `center`,
29+
noWrap = false,
30+
paddingVertical = ``,
31+
paddingHorizontal = ``,
32+
displayBlock = false,
33+
displayAnchor = false,
34+
iconSize = ``,
35+
// -
36+
...rest
37+
}) {
38+
const styleProp = { ...(rest.style || {}) }
39+
40+
if (fontSize) styleProp[`--fu-component-button-font-size`] = emify(fontSize)
41+
42+
if (color) styleProp[`--fu-component-button-color`] = `var(--color-${color})`
43+
44+
if (borderColor)
45+
styleProp[`--fu-component-button-border-color`] =
46+
borderColor === true || borderColor === `currentcolor`
47+
? `currentcolor`
48+
: `var(--color-${borderColor})`
49+
50+
if (backgroundColor)
51+
styleProp[`--fu-component-button-background-color`] =
52+
`var(--color-${backgroundColor})`
53+
54+
if (boxShadow)
55+
styleProp[`--fu-component-button-box-shadow`] = `var(--bs-${boxShadow})`
56+
57+
if (paddingVertical)
58+
styleProp[`--fu-component-button-padding-vertical`] = emify(paddingVertical)
59+
60+
if (paddingHorizontal)
61+
styleProp[`--fu-component-button-padding-horizontal`] =
62+
emify(paddingHorizontal)
63+
64+
if (iconSize) styleProp[`--fu-component-button-icon-size`] = iconSize
65+
66+
const modifierClassnames = []
67+
if (align) modifierClassnames.push(`--align-${align}`)
68+
if (noWrap) modifierClassnames.push(`--no-wrap`)
69+
if (displayBlock) modifierClassnames.push(`--display-block`)
70+
if (displayAnchor) modifierClassnames.push(`typo-a`)
71+
72+
const ariaLabel =
73+
rest[`aria-label`] || (rest.title && !children ? rest.title : undefined)
74+
75+
const Component = href
76+
? typeof href === `string` && href.trim().startsWith(`#`)
77+
? `a`
78+
: NextLink || `a`
79+
: tag
80+
81+
return (
82+
<Component
83+
{...rest}
84+
className={clsx(style.container, className, ...modifierClassnames)}
85+
style={styleProp}
86+
type={href || tag != `button` ? undefined : type}
87+
href={href}
88+
aria-label={ariaLabel}
89+
aria-busy={loading ? true : undefined}
90+
>
91+
{loading && (
92+
<span className={style.icon}>
93+
<IconLoading aria-hidden="true" />
94+
</span>
95+
)}
96+
97+
{(Icon || iconSrc) && !loading && (
98+
<span className={clsx(style.icon, `--icon`)} aria-hidden="true">
99+
{Icon ? <Icon /> : <img src={iconSrc} loading="lazy" alt="" />}
100+
</span>
101+
)}
102+
103+
{(text || children) && (
104+
<span className={style.text}>{text || children}</span>
105+
)}
106+
107+
{badge != `` && <span className={style.badge}>{badge}</span>}
108+
109+
{IconExtra && (
110+
<span className={style.icon} aria-hidden="true">
111+
<IconExtra />
112+
</span>
113+
)}
114+
</Component>
115+
)
116+
})
117+
118+
export default ButtonMemoized
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
.container {
2+
--this-gap: emify(16);
3+
4+
padding: var(--fu-component-button-padding-vertical, emify(12))
5+
var(--fu-component-button-padding-horizontal, emify(22));
6+
display: inline-flex;
7+
justify-content: center;
8+
align-items: center;
9+
gap: var(--this-gap);
10+
font-size: var(--fu-component-button-font-size, emify(16));
11+
color: var(--fu-component-button-color);
12+
background-color: var(--fu-component-button-background-color, transparent);
13+
border-color: var(--fu-component-button-border-color, transparent);
14+
border-width: var(--fu-component-button-border-width, 1px);
15+
border-style: solid;
16+
border-radius: var(--fu-component-button-border-radius);
17+
box-shadow: var(--fu-component-button-box-shadow);
18+
outline-offset: emify(6);
19+
outline-color: var(--color-active);
20+
21+
&[disabled] {
22+
cursor: not-allowed;
23+
}
24+
25+
&:is(a, button):not([disabled]) {
26+
@mixin hover;
27+
}
28+
29+
&:global(.--align-left) {
30+
justify-content: left;
31+
}
32+
33+
&:global(.--display-block) {
34+
width: 100%;
35+
display: flex;
36+
}
37+
38+
/* icon-only */
39+
&:not(:has(.text)) {
40+
aspect-ratio: 1 / 1;
41+
padding: var(--fu-component-button-icon-only-padding, emify(10));
42+
border-radius: var(
43+
--fu-component-button-icon-only-border-radius,
44+
var(--fu-component-button-border-radius)
45+
);
46+
}
47+
}
48+
49+
.text {
50+
font-family: var(--fu-component-button-text-font-family, var(--ff-primary));
51+
font-size: var(--fu-component-button-text-font-size, emify(16));
52+
font-weight: var(--fu-component-button-text-font-weight);
53+
54+
.container:global(.--no-wrap) & {
55+
@mixin text-overflow;
56+
}
57+
58+
.container:global(.--case-upper) & {
59+
font-weight: var(--fu-component-button-text-fw-case-upper);
60+
text-transform: uppercase;
61+
}
62+
}
63+
64+
.badge {
65+
margin-left: calc(var(--this-gap) / -2);
66+
padding: emify(1 6);
67+
font-size: emify(11);
68+
color: var(--fu-component-button-background-color, var(--color-background));
69+
background-color: var(--fu-component-button-color, var(--color-text));
70+
border-radius: calc(var(--fu-component-button-br) * 2);
71+
}
72+
73+
.icon {
74+
flex-shrink: 0;
75+
rotate: var(--fu-component-button-icon-rotate);
76+
77+
&:global {
78+
transition: rotate 0.4s var(--easing-out-back);
79+
80+
@media (prefers-reduced-motion) {
81+
transition: none;
82+
}
83+
}
84+
85+
.text ~ & {
86+
.container:global(.--align-left) & {
87+
margin-left: auto;
88+
}
89+
}
90+
91+
& :is(svg, img) {
92+
width: calc(emify(20) * var(--fu-component-button-icon-size, 1));
93+
height: calc(emify(20) * var(--fu-component-button-icon-size, 1));
94+
margin: calc(emify(-3) * var(--fu-component-button-icon-size, 1));
95+
scale: var(--fu-component-button-icon-scale, 1);
96+
display: block;
97+
}
98+
}

src/css/colors.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
:root {
2+
--color-black: #000;
3+
--color-white: #fff;
4+
--color-gunmetal: #08292f;
5+
--color-eagle-green: #0c3e47;
6+
--color-cadet: #5c6c76;
7+
--color-slate-gray: #627885;
8+
--color-dark-slate-gray: #325e58;
9+
--color-light-gray: #d8d8d8;
10+
--color-alloy-orange: #ba5b00;
11+
--color-alice-blue: #ebf1f3;
12+
--color-pewter-blue: #869ba1;
13+
--color-maximum-red: #dc1e1e;
14+
--color-carmine: #961919;
15+
--color-sea-green: #1a8745;
16+
--color-indigo-dye: #1f4675;
17+
--color-russet: #7f532a;
18+
--color-maximum-purple: #7c458f;
19+
--color-fuchsia-rose: #b83069;
20+
--color-teal-blue: #2b7e9a;
21+
--color-cyber-yellow: #ffd200;
22+
--color-timberwolf: #e2dbd2;
23+
--color-khaki-web: #c6b9a6;
24+
--color-celadon: #bbdbc8;
25+
--color-vanilla: #fff2b3;
26+
--color-desert-sand: #ebceb3;
27+
--color-light-blue: #c0d9e1;
28+
--color-tea-rose: #f5bcbc;
29+
30+
/* by function: */
31+
--color-facebook: #1877f2;
32+
}

src/icons/adjustments.svg

Lines changed: 3 additions & 0 deletions
Loading

src/icons/book-open-outline.svg

Lines changed: 3 additions & 0 deletions
Loading

src/icons/book-open.svg

Lines changed: 3 additions & 0 deletions
Loading

src/icons/bus.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)