Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release/v4.0.0-beta.2' into re…
Browse files Browse the repository at this point in the history
…lease/v4.0.0-beta.2
  • Loading branch information
chaiwattsw committed Apr 12, 2024
2 parents d62aa2d + fa6ba7e commit d4c2abe
Show file tree
Hide file tree
Showing 273 changed files with 8,867 additions and 1,747 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
STORYBOOK_API_KEY: ${{ secrets.STORYBOOK_API_KEY }}
STORYBOOK_USER1: ${{ secrets.STORYBOOK_USER1 }}
STORYBOOK_USER2: ${{ secrets.STORYBOOK_USER2 }}
STORYBOOK_USER3: ${{ secrets.STORYBOOK_USER3 }}
STORYBOOK_USER4: ${{ secrets.STORYBOOK_USER4 }}
STORYBOOK_USER5: ${{ secrets.STORYBOOK_USER5 }}
STORYBOOK_USER6: ${{ secrets.STORYBOOK_USER6 }}

steps:
- name: git checkout
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
STORYBOOK_API_KEY: ${{ secrets.STORYBOOK_API_KEY }}
STORYBOOK_USER1: ${{ secrets.STORYBOOK_USER1 }}
STORYBOOK_USER2: ${{ secrets.STORYBOOK_USER2 }}
STORYBOOK_USER3: ${{ secrets.STORYBOOK_USER3 }}
STORYBOOK_USER4: ${{ secrets.STORYBOOK_USER4 }}
STORYBOOK_USER5: ${{ secrets.STORYBOOK_USER5 }}
STORYBOOK_USER6: ${{ secrets.STORYBOOK_USER6 }}

steps:
- name: git checkout
Expand Down
60 changes: 30 additions & 30 deletions .storybook/decorators/UiKitDecorator.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useCallback, useEffect, useRef } from 'react';
import UiKitProvider from '../../src/core/providers/UiKitProvider';

import React, { useCallback } from 'react';
import { AmityUIKitProvider } from '../../src/v4/core/providers';
import { Preview } from '@storybook/react';
import amityConfig from '../../amity-uikit.config.json';

const GLOBAL_NAME = 'user';
export type AmityUIKitConfig = typeof amityConfig;

const GLOBAL_NAME = 'user';
const global = {
[GLOBAL_NAME]: {
name: 'User selector',
Expand All @@ -13,10 +14,7 @@ const global = {
toolbar: {
icon: 'user',
items: [
{
value: 'Web-Test,Web-Test',
title: 'Web-Test',
},
{ value: 'Web-Test,Web-test', title: 'Web-Test' },
{
value: import.meta.env.STORYBOOK_USER1,
title: import.meta.env.STORYBOOK_USER1?.split(',')[1],
Expand All @@ -25,27 +23,36 @@ const global = {
value: import.meta.env.STORYBOOK_USER2,
title: import.meta.env.STORYBOOK_USER2?.split(',')[1],
},
{
value: import.meta.env.STORYBOOK_USER3,
title: import.meta.env.STORYBOOK_USER3?.split(',')[1],
},
{
value: import.meta.env.STORYBOOK_USER4,
title: import.meta.env.STORYBOOK_USER4?.split(',')[1],
},
{
value: import.meta.env.STORYBOOK_USER5,
title: import.meta.env.STORYBOOK_USER5?.split(',')[1],
},
{
value: import.meta.env.STORYBOOK_USER6,
title: import.meta.env.STORYBOOK_USER6?.split(',')[1],
},
],
},
},
};

const FALLBACK_USER = 'Web-Test,Web-Test';

const apiKey = import.meta.env.STORYBOOK_API_KEY;
const apiRegion = import.meta.env.STORYBOOK_API_REGION;

const decorator: NonNullable<Preview['decorators']> = (
const decorator: NonNullable<Preview['decorators']>[number] = (
Story,
{ globals: { [GLOBAL_NAME]: val } },
{ globals: { [GLOBAL_NAME]: val, theme } },
) => {
const user = val || FALLBACK_USER;
const [userId, displayName] = user.split(',');

const ref = useRef<{ logout: () => void; login: () => Promise<void> } | null>(null);

console.log('-------------------', val);

const handleConnectionStatusChange = useCallback((...args) => {
console.log(`[UiKitProvider.handleConnectionStatusChange]`, ...args);
}, []);
Expand All @@ -58,28 +65,21 @@ const decorator: NonNullable<Preview['decorators']> = (
console.log(`[UiKitProvider.handleDisconnected]`, ...args);
}, []);

useEffect(() => {
ref.current?.logout();
ref.current?.login();
}, [userId]);

return (
<UiKitProvider
<AmityUIKitProvider
apiKey={import.meta.env.STORYBOOK_API_KEY}
apiRegion={import.meta.env.STORYBOOK_API_REGION}
key={userId}
apiKey={apiKey}
apiRegion={apiRegion}
userId={userId}
displayName={displayName || userId}
onConnectionStatusChange={handleConnectionStatusChange}
onConnected={handleConnected}
onDisconnected={handleDisconnected}
configs={amityConfig}
>
{Story()}
</UiKitProvider>
</AmityUIKitProvider>
);
};

export default {
global,
decorator,
};
export default { global, decorator };
2 changes: 2 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const preview: Preview = {
['Social', 'Chat'],
'Utilities',
'Assets',
'V4',
['Chat'],
],
},
},
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
169 changes: 105 additions & 64 deletions amity-uikit.config.json
Original file line number Diff line number Diff line change
@@ -1,133 +1,174 @@
{
"global_theme": {
"light_theme": {
"preferred_theme": "default",
"theme": {
"light": {
"primary_color": "#1054DE",
"secondary_color": "#292B32"
"secondary_color": "#292B32",
"base_color": "#292b32",
"base_shade1_color": "#636878",
"base_shade2_color": "#898e9e",
"base_shade3_color": "#a5a9b5",
"base_shade4_color": "#ebecef",
"alert_color": "#FA4D30",
"background_color": "#FFFFFF"
},
"dark": {
"primary_color": "#1054DE",
"secondary_color": "#292B32",
"base_color": "#ebecef",
"base_shade1_color": "#a5a9b5",
"base_shade2_color": "#6e7487",
"base_shade3_color": "#40434e",
"base_shade4_color": "#292b32",
"alert_color": "#FA4D30",
"background_color": "#191919"
}
},
"excludes": [],
"customizations": {
"select_target_page/*/*": {
"page_theme": {
"light_theme": {
"primary_color": "#1054DE",
"secondary_color": "#292B32"
}
},
"theme": {},
"title": "Share to"
},
"select_target_page/*/back_button": {
"back_icon": "back"
"theme": {},
"back_icon": "back.png"
},

"camera_page/*/*": {
"resolution": "720p",
"page_theme": {
"light_theme": {
"primary_color": "#1054DE",
"secondary_color": "#292B32"
}
}
"theme": {},
"resolution": "720p"
},
"camera_page/*/close_button": {
"close_icon": "close",
"background_color": "#80000000"
"theme": {},
"close_icon": "close.png"
},
"create_story_page/*/*": {
"theme": {}
},
"create_story_page/*/*": {},
"create_story_page/*/back_button": {
"back_icon": "back",
"background_color": "#80000000"
"theme": {},
"back_icon": "back.png",
"background_color": ""
},
"create_story_page/*/aspect_ratio_button": {
"aspect_ratio_icon": "aspect_ratio",
"background_color": "#80000000"
"theme": {},
"aspect_ratio_icon": "aspect_ratio.png",
"background_color": ""
},
"create_story_page/*/story_hyperlink_button": {
"hyperlink_button_icon": "hyperlink_button",
"theme": {},
"hyperlink_button_icon": "hyperlink_button.png",
"background_color": ""
},
"create_story_page/*/hyper_link": {
"hyper_link_icon": "hyper_link",
"theme": {},
"hyper_link_icon": "hyper_link.png",
"background_color": ""
},
"create_story_page/*/share_story_button": {
"share_icon": "share_story_button",
"background_color": "#FFFFFF",
"theme": {},
"share_icon": "share_story_button.png",
"background_color": "",
"hide_avatar": false
},
"story_page/*/*": {},
"story_page/*/progress_bar": {},
"story_page/*/*": {
"theme": {}
},
"story_page/*/progress_bar": {
"theme": {},
"progress_color": "",
"background_color": ""
},
"story_page/*/overflow_menu": {
"overflow_menu_icon": "threeDot"
"theme": {},
"overflow_menu_icon": "threeDot.png"
},
"story_page/*/close_button": {
"close_icon": "close"
"theme": {},
"close_icon": "close.png"
},
"story_page/*/story_impression_button": {
"impression_icon": "impressionIcon"
"theme": {},
"impression_icon": "impressionIcon.png"
},
"story_page/*/story_comment_button": {
"comment_icon": "comment"
"theme": {},
"comment_icon": "comment.png",
"background_color": ""
},
"story_page/*/story_reaction_button": {
"reaction_icon": "like",
"background_color": "#1243EE"
"theme": {},
"reaction_icon": "like.png",
"background_color": ""
},
"story_page/*/create_new_story_button": {
"create_new_story_icon": "plus",
"background_color": "#1243EE"
"theme": {},
"create_new_story_icon": "plus.png",
"background_color": "#ffffff"
},
"story_page/*/speaker_button": {
"mute_icon": "mute",
"unmute_icon": "unmute"
"theme": {},
"mute_icon": "mute.png",
"unmute_icon": "unmute.png",
"background_color": ""
},

"*/edit_comment_component/*": {
"component_theme": {
"light_theme": {
"primary_color": "#1054DE",
"secondary_color": "#292B32"
}
}
"theme": {}
},
"*/edit_comment_component/cancel_button": {
"theme": {},
"cancel_icon": "",
"cancel_button_text": "Cancel",
"background_color": "#FFFFFF"
"cancel_button_text": "cancel",
"background_color": ""
},
"*/edit_comment_component/save_button": {
"theme": {},
"save_icon": "",
"save_button_text": "Save",
"background_color": "#1054DE"
"background_color": ""
},

"*/hyper_link_config_component/*": {
"component_theme": {
"light_theme": {
"primary_color": "",
"secondary_color": ""
}
}
"theme": {}
},
"*/hyper_link_config_component/done_button": {
"theme": {},
"done_icon": "",
"done_button_text": "",
"done_button_text": "Done",
"background_color": ""
},
"*/hyper_link_config_component/cancel_button": {
"theme": {},
"cancel_icon": "",
"cancel_button_text": ""
"cancel_button_text": "Cancel"
},
"*/comment_tray_component/*": {
"theme": {}
},
"*/story_tab_component/*": {
"theme": {}
},
"*/comment_tray_component/*": {},
"*/story_tab_component/*": {},
"*/story_tab_component/story_ring": {
"theme": {},
"progress_color": ["#339AF9", "#78FA58"],
"fail_color": ["#FA4D30"],
"background_color": ["#EBECEF"]
"background_color": ""
},
"*/story_tab_component/create_new_story_button": {
"create_new_story_icon": "plus",
"background_color": "#1243EE"
"theme": {},
"create_new_story_icon": "plus.png",
"background_color": ""
},
"*/*/close_button": {
"close_icon": "close"
"theme": {},
"close_icon": "close.png"
},
"live_chat/*/*": {},
"live_chat/chat_header/*": {},
"live_chat/message_list/*": {},
"live_chat/message_composer/*": {
"placeholder_text": "Write a message"
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"ts-jest": "^29.1.1",
"tsup": "^7.3.0",
"typescript": "^4.9.5",
"typescript-plugin-css-modules": "^5.1.0",
"vite": "^4.5.1",
"vite-tsconfig-paths": "^4.2.3"
},
Expand Down
Loading

0 comments on commit d4c2abe

Please sign in to comment.