开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.
fix(tutorial): fix tutorial instruction issues and update styles (#289)
pubuzhixing89fd1c6a13336
diff --git a/apps/web/src/app/app.tsx b/apps/web/src/app/app.tsxindex 8c861ae..486c367 100644--- a/apps/web/src/app/app.tsx+++ b/apps/web/src/app/app.tsx@@ -3,6 +3,12 @@ import { Drawnix } from '@drawnix/drawnix';import { PlaitBoard, PlaitElement, PlaitTheme, Viewport } from '@plait/core';import localforage from 'localforage';+type AppValue = {+ children: PlaitElement[];+ viewport?: Viewport;+ theme?: PlaitTheme;+};+const MAIN_BOARD_CONTENT_KEY = 'main_board_content';localforage.config({@@ -12,24 +18,24 @@ localforage.config({});export function App() {- const [value, setValue] = useState<{- children: PlaitElement[];- viewport?: Viewport;- theme?: PlaitTheme;- }>({ children: [] });+ const [value, setValue] = useState<AppValue>({ children: [] });const [tutorial, setTutorial] = useState(false);useEffect(() => {const loadData = async () => {- const storedData = await localforage.getItem(MAIN_BOARD_CONTENT_KEY);+ const storedData = (await localforage.getItem(+ MAIN_BOARD_CONTENT_KEY+ )) as AppValue;if (storedData) {- setValue(storedData as any);+ setValue(storedData);+ if (storedData.children && storedData.children.length === 0) {+ setTutorial(true);+ }return;}setTutorial(true);};-loadData();}, []);return (@@ -38,8 +44,12 @@ export function App() {viewport={value.viewport}theme={value.theme}onChange={(value) => {- localforage.setItem(MAIN_BOARD_CONTENT_KEY, value);- setValue(value);+ const newValue = value as AppValue;+ localforage.setItem(MAIN_BOARD_CONTENT_KEY, newValue);+ setValue(newValue);+ if (newValue.children && newValue.children.length > 0) {+ setTutorial(false);+ }}}tutorial={tutorial}afterInit={(board) => {diff --git a/packages/drawnix/src/components/tutorial.scss b/packages/drawnix/src/components/tutorial.scssindex e2ceb8c..b5a07fa 100644--- a/packages/drawnix/src/components/tutorial.scss+++ b/packages/drawnix/src/components/tutorial.scss@@ -1,196 +1,117 @@.drawnix-tutorial {+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Noto Sans', 'Noto Sans CJK SC', 'Microsoft Yahei', 'Hiragino Sans GB', Arial, sans-serif;position: fixed;top: 0;left: 0;width: 100%;height: 100%;- z-index: 9999;pointer-events: none;background-color: transparent;-}--.tutorial-overlay {- position: absolute;- width: 100%;- height: 100%;- pointer-events: none;- display: flex;- justify-content: center;- align-items: center;-}--.tutorial-content {- position: relative;- width: 100%;- height: 100%;- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;-}--.language-switcher {- position: absolute;- top: 20px;- right: 20px;- padding: 8px 15px;- background-color: rgba(200, 200, 200, 0.2);- border: 1px solid rgba(150, 150, 150, 0.2);- border-radius: 20px;- color: #666;- font-family: 'Times New Roman', serif;- font-size: 14px;- cursor: pointer;- transition: all 0.3s ease;-}--.language-switcher:hover {- background-color: rgba(200, 200, 200, 0.4);-}--.brand-title {- font-family: 'Garamond', 'Times New Roman', serif;- font-size: 72px;- font-weight: 400;- color: #333;- margin-bottom: 10px;- letter-spacing: 2px;-}--.brand-description {- font-family: 'Garamond', 'Times New Roman', serif;- font-size: 18px;- color: #777;- text-align: center;- max-width: 600px;- line-height: 1.6;- margin-bottom: 60px;- font-style: italic;-}--.feature-pointer {- position: absolute;- width: 220px;-}--.top-left {- position: absolute;- top: 150px;- left: 150px;-}--.top-center {- top: 125px;- left: 50%;- transform: translateX(-50%);-}--.bottom-right {- bottom: 225px;- right: 225px;-}--.bottom-right .pointer-arrow-svg {- position: absolute;- left: 100%;- top: 100%;-}--.pointer-arrow:after {- content: '';- position: absolute;- width: 8px;- height: 8px;- border-radius: 50%;- background-color: #888;- transform: translate(-4px, -4px);-}--.pointer-content {- margin: 15px;- margin-top: -30px;-}--.top-right .pointer-content,-.bottom-right .pointer-content {- text-align: right;- padding-right: 10px;- padding-left: 0;-}--.top-center .pointer-content {- position: absolute;- left: 25%;- width: 200px;- top: 60%;-}--.top-center .pointer-content h3 {- text-align: center;-}--.top-center .pointer-content p {- text-align: center;-}--.pointer-content h3 {- font-family: 'Garamond', 'Times New Roman', serif;- font-size: 18px;- color: #555;- margin-bottom: 8px;- font-weight: normal;-}--.pointer-content p {- font-family: 'Garamond', 'Times New Roman', serif;- font-size: 14px;- color: #888;- line-height: 1.5;- margin-bottom: 5px;-}+ p {+ margin: 0;+ font-size: 14px;+ color: #888;+ line-height: 1.5;+ }-.drawnix--mobile{- .pointer-content, .pointer-arrow-svg {- display: none;+ .tutorial-overlay {+ position: absolute;+ width: 100%;+ height: 100%;+ pointer-events: none;+ display: flex;+ justify-content: center;+ align-items: center;}-}-@media screen and (max-width: 768px){.tutorial-content {- width: 95%;- height: 95%;+ position: relative;+ width: 100%;+ height: 100%;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;}-+.brand-title {- font-size: 42px;- margin-top: 20px;+ font-size: 72px;+ font-weight: 400;+ color: #333;+ letter-spacing: 2px;+ margin: 0;+ margin-bottom: 25px;}-+.brand-description {- font-size: 14px;- max-width: 300px;- margin-bottom: 30px;+ font-size: 18px;+ color: #333;+ text-align: center;+ max-width: 600px;+ line-height: 1.6;+ font-style: italic;+ margin-bottom: 25px;+ }++ .brand-tooltip {+ color: #888;+ text-align: center;+ max-width: 600px;+ line-height: 1.6;+ margin-bottom: 40px;}-+.feature-pointer {- width: 180px;+ position: absolute;}-- .feature-pointer.mobile {- position: relative;- margin: 15px 0;- top: auto;- left: auto;- right: auto;- bottom: auto;- transform: none;- display: flex;- flex-direction: column;- align-items: center;++ .top-left {+ position: absolute;+ top: 100px;+ left: 60px;+ .pointer-content {+ position: absolute;+ top: 100px;+ width: 100%;+ text-align: center;+ left: 20px;+ }+ }++ .top-center {+ top: 100px;+ left: 50%;+ width: 200px;+ transform: translateX(-50%);+ .pointer-content {+ position: absolute;+ width: 100%;+ top: 50px;+ left: 60px;+ }}-- .pointer-content, .pointer-arrow-svg {- display: none;++ .bottom-right {+ bottom: 70px;+ right: 40px;+ .pointer-content {+ position: absolute;+ top: -30px;+ right: 80px;+ width: 100%;+ }}+}+@media screen and (max-width: 768px){+ .drawnix-tutorial {+ .tutorial-content {+ width: 95%;+ height: 95%;+ }++ .feature-pointer {+ display: none;+ }+ }}\ No newline at end of filediff --git a/packages/drawnix/src/drawnix.tsx b/packages/drawnix/src/drawnix.tsxindex eb48ceb..5b8c2aa 100644--- a/packages/drawnix/src/drawnix.tsx+++ b/packages/drawnix/src/drawnix.tsx@@ -139,7 +139,13 @@ export const Drawnix: React.FC<DrawnixProps> = ({setBoard(board as DrawnixBoard);afterInit && afterInit(board);}}- ></Board>+ >+ {tutorial &&+ board &&+ PlaitBoard.isPointer(board, PlaitPointerType.selection) && (+ <Tutorial />+ )}+ </Board><AppToolbar></AppToolbar><CreationToolbar></CreationToolbar><ZoomToolbar></ZoomToolbar>@@ -151,7 +157,6 @@ export const Drawnix: React.FC<DrawnixProps> = ({<CleanConfirm container={containerRef.current}></CleanConfirm></Wrapper></div>- {tutorial && !value.length && <Tutorial/>}</DrawnixContext.Provider></I18nProvider>);