diff --git a/package.json b/package.json index 6eacca002..3f8bc8af8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ably/ui", - "version": "14.1.5", + "version": "14.1.7", "description": "Home of the Ably design system library ([design.ably.com](https://design.ably.com)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.", "repository": { "type": "git", diff --git a/src/core/Meganav/Meganav.stories.tsx b/src/core/Meganav/Meganav.stories.tsx index 2152cd029..31bf05b4b 100644 --- a/src/core/Meganav/Meganav.stories.tsx +++ b/src/core/Meganav/Meganav.stories.tsx @@ -1,6 +1,5 @@ import React, { useEffect } from "react"; import { http, HttpResponse } from "msw"; - import Meganav from "../Meganav"; import loadIcons from "../icons.js"; import logo from "../images/ably-logo.png"; @@ -26,7 +25,18 @@ export default { msw: { handlers: [ http.get("/api/me", () => { - return HttpResponse.json({}); + return HttpResponse.json({ + accountName: "Account Name", + signedIn: true, + account: { + links: { + dashboard: { + text: "Dashboard", + href: "/accounts/1", + }, + }, + }, + }); }), http.get("/api/blog", () => { return HttpResponse.json([ @@ -66,7 +76,7 @@ const Page = () => { const store = getRemoteDataStore(); - fetchSessionData(store, "/api/me"); + fetchSessionData(store, ""); fetchBlogPosts(store, "/api/blog"); }, []); @@ -84,3 +94,26 @@ const Page = () => { export const Default = { render: () => , }; + +const PageSignedIn = () => { + useEffect(() => { + loadIcons(); + const store = getRemoteDataStore(); + fetchSessionData(store, "/api/me"); + fetchBlogPosts(store, "/api/blog"); + }, []); + + return ( + + ); +}; + +export const SignedIn = { + render: () => , +}; diff --git a/src/core/MeganavItemsSignedIn.tsx b/src/core/MeganavItemsSignedIn.tsx index 70b78891d..f60a7e0cc 100644 --- a/src/core/MeganavItemsSignedIn.tsx +++ b/src/core/MeganavItemsSignedIn.tsx @@ -1,7 +1,4 @@ import React from "react"; - -import MeganavControl from "./MeganavControl"; -import SignOutLink from "./SignOutLink"; import MeganavSearch from "./MeganavSearch"; import { AbsUrl, MeganavSessionState, MeganavTheme } from "./Meganav"; @@ -11,7 +8,7 @@ type MeganavItemsSignedIn = { absUrl: AbsUrl; }; -const truncate = (string, length) => { +const truncate = (string: string, length: number) => { return string?.length && string.length > length ? `${string.slice(0, length - 1)}…` : string; @@ -19,94 +16,16 @@ const truncate = (string, length) => { const MeganavItemsSignedIn = ({ sessionState, - theme, absUrl, }: MeganavItemsSignedIn) => { - const links = sessionState.account - ? Object.keys(sessionState.account.links).map( - (key) => sessionState.account.links[key], - ) - : []; const accountName = truncate(sessionState.accountName, 20); - const preferredEmail = truncate(sessionState.preferredEmail, 20); return (