Skip to content

Commit

Permalink
Merge branch 'feature/contextual-Tutorials' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Mar 2, 2024
2 parents aea1b6e + 1cd39d5 commit 6385474
Show file tree
Hide file tree
Showing 20 changed files with 583 additions and 118 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
9 changes: 6 additions & 3 deletions src/annotations/components/AnnotationCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,11 @@ export class AnnotationCreate extends React.Component<Props, State>
shouldShare: boolean,
isProtected?: boolean,
) => {
if (this.state.isDeboucingEditor) {
await sleepPromise(250)
if (!this.editor?.checkIfHasContent()) {
return
}
while (this.state.isDeboucingEditor) {
await sleepPromise(50)
}
const saveP = this.props.onSave(shouldShare, isProtected)
this.setState({ toggleShowTutorial: false, onEditClick: false })
Expand Down Expand Up @@ -407,7 +410,7 @@ export class AnnotationCreate extends React.Component<Props, State>
autoFocus={
this.props.autoFocus || this.state.onEditClick
}
placeholder={`Write a note...`}
// placeholder={`Write a note...`}
isRibbonCommentBox={this.props.isRibbonCommentBox}
getYoutubePlayer={this.props.getYoutubePlayer}
sidebarEvents={this.props.sidebarEvents}
Expand Down
1 change: 1 addition & 0 deletions src/citations/PageCitations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ShareAnnotationMenu from 'src/overview/sharing/components/ShareAnnotation
import { RemoteSyncSettingsInterface } from 'src/sync-settings/background/types'
import { AnnotationSharingState } from 'src/content-sharing/background/types'
import { PageAnnotationsCacheInterface } from 'src/annotations/cache/types'
import TutorialBox from '@worldbrain/memex-common/lib/common-ui/components/tutorial-box'

export interface Props {
copyPasterProps: Omit<CopyPasterProps, 'renderTemplate' | 'renderPreview'>
Expand Down
3 changes: 3 additions & 0 deletions src/common-ui/components/design-library/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,6 @@ export const key = browser.runtime.getURL('/img/key.svg')
export const spread = browser.runtime.getURL('/img/spread.svg')
export const dragList = browser.runtime.getURL('/img/dragList.svg')
export const memexIconOnly = browser.runtime.getURL('/img/memexIconOnly.svg')
export const browserIcon = browser.runtime.getURL(
'/img/browserIcons/logo-48.png',
)
5 changes: 5 additions & 0 deletions src/copy-paster/components/TemplateEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TooltipBox } from '@worldbrain/memex-common/lib/common-ui/components/to
import { TaskState } from 'ui-logic-core/lib/types'
import LoadingIndicator from '@worldbrain/memex-common/lib/common-ui/components/loading-indicator'
import { PrimaryAction } from '@worldbrain/memex-common/lib/common-ui/components/PrimaryAction'
import TutorialBox from '@worldbrain/memex-common/lib/common-ui/components/tutorial-box'

interface TemplateEditorProps {
previewString: string
Expand Down Expand Up @@ -227,6 +228,10 @@ export default class TemplateEditor extends PureComponent<
: 'Edit Template'}
</SectionTitle>
<ButtonBox>
<TutorialBox
tutorialId="useTemplates"
getRootElement={this.props.getRootElement}
/>
{!this.props.isNew && !this.state.confirmDelete ? (
<PrimaryAction
onClick={() =>
Expand Down
9 changes: 7 additions & 2 deletions src/copy-paster/components/TemplateList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
OnDragEndResponder,
} from 'react-beautiful-dnd'
import { PrimaryAction } from '@worldbrain/memex-common/lib/common-ui/components/PrimaryAction'
import TutorialBox from '@worldbrain/memex-common/lib/common-ui/components/tutorial-box'

const Header = styled.div`
display: flex;
Expand Down Expand Up @@ -243,7 +244,11 @@ export default class TemplateList extends PureComponent<TemplateListProps> {
<Header>
<SectionTitle>Templates</SectionTitle>
<ButtonBox>
<Icon
<TutorialBox
getRootElement={this.props.getRootElement}
tutorialId={'useTemplates'}
/>
{/* <Icon
filePath={icons.helpIcon}
heightAndWidth="18px"
padding={'5px'}
Expand All @@ -252,7 +257,7 @@ export default class TemplateList extends PureComponent<TemplateListProps> {
'https://links.memex.garden/tutorials/text-exporter',
)
}
/>
/> */}

<PrimaryAction
label={'New'}
Expand Down
38 changes: 38 additions & 0 deletions src/custom-lists/ui/page-link-share-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SpaceEmailInvites from '../space-email-invites'
import SpaceLinks from '../space-links'
import { helpIcon } from 'src/common-ui/components/design-library/icons'
import { TaskState } from 'ui-logic-core/lib/types'
import TutorialBox from '@worldbrain/memex-common/lib/common-ui/components/tutorial-box'

export interface Props extends Dependencies {
showSpacesTab?: (pageUrl) => void
Expand Down Expand Up @@ -42,6 +43,20 @@ export default class PageLinkShareMenuContainer extends StatefulUIElement<
}
}

renderTutorialBox() {
if (this.state.showTutorial === false) {
return
}
return (
<TutorialBox
tutorialId={'sharePages'}
getRootElement={this.props.getRootElement}
onTutorialClose={() => this.processEvent('showTutorial', false)}
isHeadless={true}
/>
)
}

private renderMainContent() {
if (this.state.loadState === 'running') {
return (
Expand Down Expand Up @@ -79,6 +94,15 @@ export default class PageLinkShareMenuContainer extends StatefulUIElement<
software.
</Subtitle>
</TitleSection>
<TutorialButtonContainer>
<TutorialBox
tutorialId={'sharePages'}
getRootElement={this.props.getRootElement}
onTutorialClose={() =>
this.processEvent('showTutorial', false)
}
/>
</TutorialButtonContainer>
</ContextMenuContainer>
)
}
Expand Down Expand Up @@ -106,7 +130,14 @@ export default class PageLinkShareMenuContainer extends StatefulUIElement<
icon={helpIcon}
heightAndWidth={'16px'}
hoverOff
onClick={() => {
this.processEvent(
'showTutorial',
true,
)
}}
/>
{this.renderTutorialBox()}
</TooltipBox>
</SectionTitle>
<TooltipBox
Expand Down Expand Up @@ -303,6 +334,7 @@ const ContextMenuContainer = styled.div`
width: fill-available;
justify-content: center;
align-items: center;
position: relative;
/* width: 250px; */
`

Expand Down Expand Up @@ -493,3 +525,9 @@ const BigNewButtonBox = styled.div`
width: -moz-available;
padding: 0 15px;
`

const TutorialButtonContainer = styled.div`
position: absolute;
right: 5px;
bottom: 5px;
`
6 changes: 6 additions & 0 deletions src/custom-lists/ui/page-link-share-menu/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type Event = UIEvent<{
createPageLink: null
copyInviteLink: { link: string }
reloadInviteLinks: { listData: UnifiedList<'page-link'> }
showTutorial: boolean
}>

export interface State {
Expand All @@ -50,6 +51,7 @@ export interface State {
inviteLinksLoadState: TaskState
inviteLinks: InviteLink[]
selectedPageLinkList: UnifiedList<'page-link'> | null
showTutorial: boolean
}

type EventHandler<EventName extends keyof Event> = UIEventHandler<
Expand All @@ -72,6 +74,7 @@ export default class PageLinkShareMenu extends UILogic<State, Event> {
inviteLinksLoadState: 'pristine',
inviteLinks: [],
selectedPageLinkList: null,
showTutorial: false,
})

private async ensureLoggedInUser(): Promise<AuthenticatedUser> {
Expand Down Expand Up @@ -195,6 +198,9 @@ export default class PageLinkShareMenu extends UILogic<State, Event> {
})
}

showTutorial: EventHandler<'showTutorial'> = async ({ event }) => {
this.emitMutation({ showTutorial: { $set: event } })
}
createPageLink: EventHandler<'createPageLink'> = async ({}) => {
await this._createPageLink()
}
Expand Down
5 changes: 3 additions & 2 deletions src/dashboard-refactor/header/search-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ const Input = styled.input`
}
&:focus {
outline: none;
outline: none !important;
}
&:focus ${SearchBarContainer} {
outline: 1px solid ${(props) => props.theme.colors.greyScale3};
outline: 1px solid ${(props) => props.theme.colors.greyScale3} !important;
}
`

Expand All @@ -231,6 +231,7 @@ const FilterButton = styled(Margin)`

const FullWidthMargin = styled(Margin)`
width: 100%;
height: fill-available;
`

const SearchIcon = styled.img`
Expand Down
5 changes: 3 additions & 2 deletions src/dashboard-refactor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export class DashboardContainer extends StatefulUIElement<
| 'openSpaceInWebUI'
| 'summarizeBG'
| 'imageSupportBG'
| 'getRootElement'
> = {
analytics,
copyToClipboard,
Expand Down Expand Up @@ -154,7 +153,6 @@ export class DashboardContainer extends StatefulUIElement<
openSpaceInWebUI: (remoteListId) =>
window.open(getListShareUrl({ remoteListId }), '_blank'),
imageSupportBG: runInBackground(),
getRootElement: () => document.getElementById('body'),
}

private notesSidebarRef = React.createRef<NotesSidebarContainer>()
Expand Down Expand Up @@ -696,6 +694,7 @@ export class DashboardContainer extends StatefulUIElement<
this.processEvent('setLocalListsExpanded', {
isExpanded: !listsSidebar.areLocalListsExpanded,
}),
getRootElement: this.props.getRootElement,
}}
followedListsGroup={{
isExpanded: listsSidebar.areFollowedListsExpanded,
Expand All @@ -708,6 +707,7 @@ export class DashboardContainer extends StatefulUIElement<
this.processEvent('setFollowedListsExpanded', {
isExpanded: !listsSidebar.areFollowedListsExpanded,
}),
getRootElement: this.props.getRootElement,
}}
joinedListsGroup={{
isExpanded: listsSidebar.areJoinedListsExpanded,
Expand All @@ -721,6 +721,7 @@ export class DashboardContainer extends StatefulUIElement<
})
},
listData: joinedListsData,
getRootElement: this.props.getRootElement,
}}
currentUser={this.state.currentUser}
initContextMenuBtnProps={(listId) => ({
Expand Down
25 changes: 18 additions & 7 deletions src/dashboard-refactor/lists-sidebar/components/sidebar-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fonts } from 'src/dashboard-refactor/styles'
import LoadingIndicator from '@worldbrain/memex-common/lib/common-ui/components/loading-indicator'
import Icon from '@worldbrain/memex-common/lib/common-ui/components/icon'
import type { TaskState } from 'ui-logic-core/lib/types'
import TutorialBox from '@worldbrain/memex-common/lib/common-ui/components/tutorial-box'

export interface Props {
title: string
Expand All @@ -14,6 +15,7 @@ export interface Props {
onAddBtnClick?: React.MouseEventHandler
onExpandBtnClick: React.MouseEventHandler
spaceSidebarWidth: string
getRootElement: () => HTMLElement
}

export default class ListsSidebarGroup extends PureComponent<Props> {
Expand Down Expand Up @@ -65,13 +67,22 @@ export default class ListsSidebarGroup extends PureComponent<Props> {
{this.props.title}
<IconGroup>
{this.props.onAddBtnClick && (
<Icon
icon="plus"
heightAndWidth="16px"
color={'prime1'}
padding={'4px'}
onClick={this.props.onAddBtnClick}
/>
<>
<TutorialBox
getRootElement={
this.props.getRootElement
}
tutorialId="organiseSpaces"
iconSize="18px"
/>
<Icon
icon="plus"
heightAndWidth="16px"
color={'prime1'}
padding={'4px'}
onClick={this.props.onAddBtnClick}
/>
</>
)}
{this.props.loadingState === 'success' && (
<Counter>{this.props.listsCount}</Counter>
Expand Down
1 change: 1 addition & 0 deletions src/dashboard-refactor/lists-sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ export default class ListsSidebar extends PureComponent<ListsSidebarProps> {
{...this.props.ownListsGroup}
listsCount={this.props.ownListsGroup.listData.length}
spaceSidebarWidth={this.props.spaceSidebarWidth}
getRootElement={this.props.getRootElement}
>
{this.props.isAddListInputShown && (
<SidebarItemInput
Expand Down
Loading

0 comments on commit 6385474

Please sign in to comment.