@krrli/cm-designsystem 1.30.0 → 1.31.0
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/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/like-toggle/LikeToggle.js +1 -0
- package/dist/components/toggle/Toggle.js +1 -0
- package/dist/compositions/image-upload-modal/ImageUploadModal.d.ts +15 -0
- package/dist/compositions/image-upload-modal/ImageUploadModal.js +21 -0
- package/dist/compositions/index.d.ts +11 -0
- package/dist/compositions/index.js +11 -0
- package/dist/compositions/post-creator/PostCreator.js +6 -5
- package/dist/compositions/profile-banner/ProfileBanner.d.ts +10 -0
- package/dist/compositions/profile-banner/ProfileBanner.js +8 -2
- package/dist/compositions/profile-banner-info/ProfileBannerInfo.js +3 -3
- package/dist/compositions/response-creator/ResponseCreator.js +6 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +2874 -2071
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ export * from "./file-upload/FileUpload";
|
|
|
6
6
|
export * from "./form/Form";
|
|
7
7
|
export * from "./icon-button/IconButton";
|
|
8
8
|
export * from "./icons/IconBase";
|
|
9
|
+
export * from "./icons/generated";
|
|
9
10
|
export * from "./input/Input";
|
|
10
11
|
export * from "./like-toggle/LikeToggle";
|
|
11
12
|
export * from "./logo-link/LogoLink";
|
package/dist/components/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./file-upload/FileUpload";
|
|
|
6
6
|
export * from "./form/Form";
|
|
7
7
|
export * from "./icon-button/IconButton";
|
|
8
8
|
export * from "./icons/IconBase";
|
|
9
|
+
export * from "./icons/generated";
|
|
9
10
|
export * from "./input/Input";
|
|
10
11
|
export * from "./like-toggle/LikeToggle";
|
|
11
12
|
export * from "./logo-link/LogoLink";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface ImageUploadModalProps {
|
|
2
|
+
/** Callback fired when the user selects a file. `null` is passed if no file is selected. */
|
|
3
|
+
onFileChange: (file: File | null) => void;
|
|
4
|
+
}
|
|
5
|
+
export type ImageUploadModalRef = {
|
|
6
|
+
/** Function that opens or closes the modal. Pass `true` to open, `false` to close. */
|
|
7
|
+
openModal: (open: boolean) => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* ImageUploadModal component
|
|
11
|
+
*
|
|
12
|
+
* Renders a post creation component.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ImageUploadModal: import("react").ForwardRefExoticComponent<ImageUploadModalProps & import("react").RefAttributes<ImageUploadModalRef>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, forwardRef, useImperativeHandle } from "react";
|
|
3
|
+
import { Button, FileUpload, Modal } from "../../components";
|
|
4
|
+
import { Cancel, Checkmark } from "../../components/icons/generated";
|
|
5
|
+
/**
|
|
6
|
+
* ImageUploadModal component
|
|
7
|
+
*
|
|
8
|
+
* Renders a post creation component.
|
|
9
|
+
*/
|
|
10
|
+
export const ImageUploadModal = forwardRef((props, ref) => {
|
|
11
|
+
const [open, setOpen] = useState(false);
|
|
12
|
+
const [file, setFile] = useState(null);
|
|
13
|
+
// Pass the ref to the useImperativeHandle hook
|
|
14
|
+
useImperativeHandle(ref, () => ({
|
|
15
|
+
openModal: setOpen,
|
|
16
|
+
}));
|
|
17
|
+
return (_jsxs(Modal, { open: open, onOpenChange: setOpen, title: "Image upload", children: [_jsx(Modal.Body, { children: _jsx(FileUpload, { onFileSelect: setFile }) }), _jsxs(Modal.Actions, { children: [_jsx(Button, { intent: "primary", size: "md", icon: Cancel, onClick: () => setOpen(false), children: "Cancel" }), _jsx(Button, { intent: "secondary", size: "md", icon: Checkmark, onClick: () => {
|
|
18
|
+
setOpen(false);
|
|
19
|
+
props.onFileChange(file);
|
|
20
|
+
}, children: "Save" })] })] }));
|
|
21
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./image-banner/ImageBanner";
|
|
2
|
+
export * from "./image-upload-modal/ImageUploadModal";
|
|
3
|
+
export * from "./post/Post";
|
|
4
|
+
export * from "./post-creator/PostCreator";
|
|
5
|
+
export * from "./profile-banner/ProfileBanner";
|
|
6
|
+
export * from "./profile-banner-image/ProfileBannerImage";
|
|
7
|
+
export * from "./profile-banner-info/ProfileBannerInfo";
|
|
8
|
+
export * from "./response/Response";
|
|
9
|
+
export * from "./response-creator/ResponseCreator";
|
|
10
|
+
export * from "./user-info/UserInfo";
|
|
11
|
+
export * from "./user-recommendation/UserRecommendation";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./image-banner/ImageBanner";
|
|
2
|
+
export * from "./image-upload-modal/ImageUploadModal";
|
|
3
|
+
export * from "./post/Post";
|
|
4
|
+
export * from "./post-creator/PostCreator";
|
|
5
|
+
export * from "./profile-banner/ProfileBanner";
|
|
6
|
+
export * from "./profile-banner-image/ProfileBannerImage";
|
|
7
|
+
export * from "./profile-banner-info/ProfileBannerInfo";
|
|
8
|
+
export * from "./response/Response";
|
|
9
|
+
export * from "./response-creator/ResponseCreator";
|
|
10
|
+
export * from "./user-info/UserInfo";
|
|
11
|
+
export * from "./user-recommendation/UserRecommendation";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Form } from "@radix-ui/react-form";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
4
|
import { tv } from "tailwind-variants";
|
|
5
|
-
import { Avatar, Button,
|
|
6
|
-
import {
|
|
5
|
+
import { Avatar, Button, Heading, Textarea } from "../../components";
|
|
6
|
+
import { Send, Upload } from "../../components/icons/generated";
|
|
7
|
+
import { ImageUploadModal, } from "../image-upload-modal/ImageUploadModal";
|
|
7
8
|
import { PostBase } from "../post-base/PostBase";
|
|
8
9
|
const PostCreatorStyles = tv({
|
|
9
10
|
slots: {
|
|
@@ -21,8 +22,8 @@ const PostCreatorStyles = tv({
|
|
|
21
22
|
*/
|
|
22
23
|
export const PostCreator = (props) => {
|
|
23
24
|
const { content, avatar, title, input, action } = PostCreatorStyles(props);
|
|
24
|
-
const [open, setOpen] = useState(false);
|
|
25
25
|
const [file, setFile] = useState(null);
|
|
26
26
|
const [text, setText] = useState("");
|
|
27
|
-
|
|
27
|
+
const imageUploadModalRef = useRef(null);
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsxs(PostBase, { children: [_jsx("div", { className: avatar(), children: _jsx(Avatar, { alt: "Profile", size: "md", src: props.src, onAvatarClick: props.onAvatarClick }) }), _jsxs(Form, { className: content(), children: [_jsx(Heading, { size: "4", as: "h4", className: title(), children: "Hey, what's up?" }), _jsx("div", { className: input(), children: _jsx(Textarea, { name: "post", placeholder: "Your opinion matters!", onChange: setText }) }), _jsxs("div", { className: action(), children: [_jsx(Button, { intent: "primary", size: "md", icon: Upload, onClick: () => imageUploadModalRef.current?.openModal(true), children: "Picture upload" }), _jsx(Button, { intent: "secondary", size: "md", icon: Send, onClick: () => props.onSendClick(text, file), children: "Send" })] })] })] }), _jsx(ImageUploadModal, { ref: imageUploadModalRef, onFileChange: setFile })] }));
|
|
28
29
|
};
|
|
@@ -64,6 +64,16 @@ interface ProfileBannerProps extends ProfileBannerVariants {
|
|
|
64
64
|
description: string;
|
|
65
65
|
/** Whether the profile being viewed belongs to the logged-in user. */
|
|
66
66
|
isCurrentUser: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Optional callback triggered when the profile/banner image changes.
|
|
69
|
+
* Receives the selected `File`, or `null` if cleared.
|
|
70
|
+
*/
|
|
71
|
+
onProfileImageChange?: (file: File | null) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Optional callback triggered when the avatar image changes.
|
|
74
|
+
* Receives the selected `File`, or `null` if cleared.
|
|
75
|
+
*/
|
|
76
|
+
onAvatarImageChange?: (file: File | null) => void;
|
|
67
77
|
}
|
|
68
78
|
/**
|
|
69
79
|
* Profile banner component for displaying user profile info.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
2
3
|
import { tv } from "tailwind-variants";
|
|
3
4
|
import { Avatar, Paragraph } from "../../components";
|
|
5
|
+
import { ImageUploadModal, } from "../image-upload-modal/ImageUploadModal";
|
|
4
6
|
import { ProfileBannerImage } from "../profile-banner-image/ProfileBannerImage";
|
|
5
7
|
import { ProfileBannerInfo } from "../profile-banner-info/ProfileBannerInfo";
|
|
6
8
|
const ProfileBannerStyles = tv({
|
|
@@ -16,5 +18,9 @@ const ProfileBannerStyles = tv({
|
|
|
16
18
|
*/
|
|
17
19
|
export const ProfileBanner = (props) => {
|
|
18
20
|
const { base, avatar, info, description } = ProfileBannerStyles(props);
|
|
19
|
-
|
|
21
|
+
const profileImageUploadModalRef = useRef(null);
|
|
22
|
+
const avatarImageUploadModalRef = useRef(null);
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: base(), children: [_jsx(ProfileBannerImage, { src: props.imageSrc, alt: props.imageAlt, onClick: () => profileImageUploadModalRef.current?.openModal(true) }), _jsx("div", { className: avatar(), children: _jsx(Avatar, { src: props.avatarSrc, alt: props.avatarAlt, size: "xl", onActionClick: props.isCurrentUser
|
|
24
|
+
? () => avatarImageUploadModalRef.current?.openModal(true)
|
|
25
|
+
: undefined }) }), _jsxs("div", { className: info(), children: [_jsx(ProfileBannerInfo, { isCurrentUser: props.isCurrentUser, displayName: props.displayName, userName: props.userName, location: props.location, joinedTimestamp: props.joinedTimestamp, onProfileClick: () => { } }), _jsx(Paragraph, { size: "md", className: description(), children: props.description })] })] }), _jsx(ImageUploadModal, { ref: profileImageUploadModalRef, onFileChange: props.onProfileImageChange ?? (() => { }) }), _jsx(ImageUploadModal, { ref: avatarImageUploadModalRef, onFileChange: props.onAvatarImageChange ?? (() => { }) })] }));
|
|
20
26
|
};
|
|
@@ -6,9 +6,9 @@ import { Label } from "../../components/typography/Label";
|
|
|
6
6
|
const profileBannerInfoStyles = tv({
|
|
7
7
|
slots: {
|
|
8
8
|
base: ["flex", "flex-col", "gap-2", "items-start"],
|
|
9
|
-
title: ["flex", "gap-1", "items-center"],
|
|
9
|
+
title: ["flex", "gap-1", "items-center", "**:cursor-pointer"],
|
|
10
10
|
icon: ["text-violet-600", "-mt-0.5"],
|
|
11
|
-
displayName: ["text-slate-900"
|
|
11
|
+
displayName: ["text-slate-900"],
|
|
12
12
|
detailInfo: ["flex", "gap-4"],
|
|
13
13
|
secondaryInfo: ["text-slate-500"],
|
|
14
14
|
},
|
|
@@ -43,5 +43,5 @@ const memberSincePrefix = "Member since ";
|
|
|
43
43
|
*/
|
|
44
44
|
export const ProfileBannerInfo = (props) => {
|
|
45
45
|
const { base, title, icon, displayName, detailInfo, secondaryInfo } = profileBannerInfoStyles(props);
|
|
46
|
-
return (_jsxs("div", { className: base(), children: [_jsxs("div", { className: title(), children: [_jsx("button", { onClick: props.onProfileClick, className: displayName(), children: _jsx(Label, { size: "xl", children: props.displayName }) }), props.isCurrentUser && _jsx(Settings, { className: icon() })] }), _jsxs("div", { className: detailInfo(), children: [_jsx(IconButton, { intent: "secondary", icon: Profile, onClick: props.onProfileClick, children: props.userName }), _jsx(IconButton, { intent: "primary", icon: Location, onClick: props.onProfileClick, className: secondaryInfo(), children: props.location }), _jsx(IconButton, { intent: "primary", icon: Calendar, onClick: props.onProfileClick, className: secondaryInfo(), children: memberSincePrefix + timeSince(props.joinedTimestamp) })] })] }));
|
|
46
|
+
return (_jsxs("div", { className: base(), children: [_jsxs("div", { className: title(), children: [_jsx("button", { onClick: props.onProfileClick, className: displayName(), children: _jsx(Label, { size: "xl", children: props.displayName }) }), props.isCurrentUser && (_jsx("button", { onClick: props.onSettingsClick, children: _jsx(Settings, { className: icon() }) }))] }), _jsxs("div", { className: detailInfo(), children: [_jsx(IconButton, { intent: "secondary", icon: Profile, onClick: props.onProfileClick, children: props.userName }), _jsx(IconButton, { intent: "primary", icon: Location, onClick: props.onProfileClick, className: secondaryInfo(), children: props.location }), _jsx(IconButton, { intent: "primary", icon: Calendar, onClick: props.onProfileClick, className: secondaryInfo(), children: memberSincePrefix + timeSince(props.joinedTimestamp) })] })] }));
|
|
47
47
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Form } from "@radix-ui/react-form";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
4
|
import { tv } from "tailwind-variants";
|
|
5
|
-
import { Button,
|
|
6
|
-
import {
|
|
5
|
+
import { Button, Textarea } from "../../components";
|
|
6
|
+
import { Send, Upload } from "../../components/icons/generated";
|
|
7
|
+
import { ImageUploadModal, } from "../image-upload-modal/ImageUploadModal";
|
|
7
8
|
import { PostBase } from "../post-base/PostBase";
|
|
8
9
|
import { UserInfo } from "../user-info/UserInfo";
|
|
9
10
|
const ResponseCreatorStyles = tv({
|
|
@@ -20,8 +21,8 @@ const ResponseCreatorStyles = tv({
|
|
|
20
21
|
*/
|
|
21
22
|
export const ResponseCreator = (props) => {
|
|
22
23
|
const { content, input, action } = ResponseCreatorStyles(props);
|
|
23
|
-
const [open, setOpen] = useState(false);
|
|
24
24
|
const [file, setFile] = useState(null);
|
|
25
25
|
const [text, setText] = useState("");
|
|
26
|
-
|
|
26
|
+
const imageUploadModalRef = useRef(null);
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsx(PostBase, { children: _jsxs(Form, { className: content(), children: [_jsx(UserInfo, { displayName: props.displayName, onClick: props.onAvatarClick, size: "sm", src: props.src, userName: props.userName }), _jsx("div", { className: input(), children: _jsx(Textarea, { name: "post", placeholder: "Your opinion matters!", onChange: setText }) }), _jsxs("div", { className: action(), children: [_jsx(Button, { intent: "primary", size: "md", icon: Upload, onClick: () => imageUploadModalRef.current?.openModal(true), children: "Picture upload" }), _jsx(Button, { intent: "secondary", size: "md", icon: Send, onClick: () => props.onSendClick(text, file), children: "Send" })] })] }) }), _jsx(ImageUploadModal, { ref: imageUploadModalRef, onFileChange: setFile })] }));
|
|
27
28
|
};
|
package/dist/index.d.ts
CHANGED