Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sharebutton visible on desktop #377

Merged
merged 4 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion demo/src/Components/DocPage/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ const DocPageDemo = (
const notification = useNotification();
const search = useSearchResults(args['Search'] || '');
const pdf = usePdf(args['Pdf'] || '');
const mobileView = Boolean(args['Mobile']);

const {lang} = langs;
const {wideFormat, showMiniToc, theme, textSize} = settings;
Expand All @@ -246,8 +247,8 @@ const DocPageDemo = (
theme,
textSize,
singlePage,
isMobile: mobileView,
};

Object.assign(
props,
...[
Expand Down Expand Up @@ -289,6 +290,9 @@ export default {
title: 'Pages/Document',
component: DocPageDemo,
argTypes: {
Mobile: {
control: 'boolean',
},
Settings: {
control: 'boolean',
},
Expand Down
5 changes: 3 additions & 2 deletions demo/src/Components/LeadingPage/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ type Args = {
};

const DocLeadingPageDemo = (args: Args) => {
const isMobile = args['Mobile'];
const theme = args['Theme'];
const router = {pathname: '/docs/compute'};
const mobileView = Boolean(args['Mobile']);

useEffect(() => {
updateBodyClassName(theme);
}, [theme]);

return (
<div className={isMobile === 'true' ? 'mobile' : 'desktop'}>
<div className={mobileView ? 'mobile' : 'desktop'}>
<div className={layoutBlock('content')}>
<DocLeadingPage
{...(pageContent as DocLeadingPageData)}
isMobile={mobileView}
wideFormat={true}
router={router}
/>
Expand Down
4 changes: 4 additions & 0 deletions src/components/DocLeadingPage/DocLeadingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {DocPageTitle} from '../DocPageTitle';
import {HTML} from '../HTML';
import {Text} from '../Text';
import {Notification, NotificationProps} from '../Notification';
import {ShareButton} from '../ShareButton';

import './DocLeadingPage.scss';

Expand All @@ -25,6 +26,7 @@ export interface DocLeadingPageProps extends DocLeadingPageData, NotificationPro
tocTitleIcon?: React.ReactNode;
useMainTag?: boolean;
legacyToc?: boolean;
isMobile?: boolean;
}

export interface DocLinkProps {
Expand Down Expand Up @@ -118,6 +120,7 @@ export const DocLeadingPage: React.FC<DocLeadingPageProps> = ({
legacyToc,
notification,
notificationCb,
isMobile,
}) => {
const modes = {
'regular-page-width': !wideFormat,
Expand All @@ -138,6 +141,7 @@ export const DocLeadingPage: React.FC<DocLeadingPageProps> = ({
<DocLayout.Center>
<Notification notification={notification} notificationCb={notificationCb} />
<ContentWrapper className={b('main')} useMainTag={useMainTag}>
{isMobile && <ShareButton className={b('share-button')} title={title} />}
<DocPageTitle stage={toc.stage} className={b('title')}>
<HTML>{title}</HTML>
</DocPageTitle>
Expand Down
5 changes: 0 additions & 5 deletions src/components/DocPage/DocPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@
&:hover::before {
background-color: transparent;
}

// ShareButton in title is currently only available on mobile devices.
@media (min-width: map.get(variables.$screenBreakpoints, 'md')) {
display: none;
}
}

&__content {
Expand Down
5 changes: 3 additions & 2 deletions src/components/DocPage/DocPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface DocPageProps extends DocPageData, DocSettings, NotificationProp
pdfLink?: string;
onMiniTocItemClick?: (event: MouseEvent) => void;
useMainTag?: boolean;
isMobile?: boolean;
}

type DocPageInnerProps = InnerProps<DocPageProps, DocSettings>;
Expand Down Expand Up @@ -403,9 +404,9 @@ class DocPage extends React.Component<DocPageInnerProps, DocPageState> {
}

private renderTitle() {
const {title, headerHeight, meta, bookmarkedPage, onChangeBookmarkPage} = this.props;
const {title, meta, bookmarkedPage, onChangeBookmarkPage, isMobile} = this.props;
const withBookmarks = onChangeBookmarkPage;
const withShare = Number(headerHeight) > 0 && !this.showMiniToc;
const withShare = isMobile;

if (!title) {
return null;
Expand Down
Loading