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

[Beta] Add EuiTour component #2766

Merged
merged 84 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
40639c7
initial commit
ryankeairns Jan 8, 2020
ffc3e89
laying groundwork for steps
ryankeairns Jan 10, 2020
0ceae7b
saving progress
ryankeairns Jan 13, 2020
5e9fc3b
saving progress
ryankeairns Jan 14, 2020
306d3f6
cleaning up some TODO items
ryankeairns Jan 15, 2020
ae2d613
use form for demo
ryankeairns Jan 15, 2020
6f0b03c
added localStorage to demo
ryankeairns Jan 16, 2020
7a2ade7
uncomment screereader only for step indicator
ryankeairns Jan 17, 2020
ab7bf20
Merge branch 'master' into rk/505-euitour
thompsongl Feb 26, 2020
8cd9369
API refactor; useEuiTour
thompsongl Feb 27, 2020
84729de
WIP
thompsongl Mar 4, 2020
84d1abe
Merge branch 'master' into rk/505-euitour
thompsongl Mar 5, 2020
9f9881f
interface and docs clean up
thompsongl Mar 5, 2020
892564b
more docs
thompsongl Mar 6, 2020
02aaf74
add goto action
thompsongl Mar 6, 2020
8ec84d5
Merge branch 'master' into rk/505-euitour
thompsongl Mar 6, 2020
5bb4bcd
Merge branch 'master' into rk/505-euitour
thompsongl Mar 12, 2020
ad1e765
refactor useEuiTour
thompsongl Mar 12, 2020
9332125
beacon component
thompsongl Mar 13, 2020
70904b5
use euibeacon
thompsongl Mar 13, 2020
0e21359
Merge branch 'master' into rk/505-euitour
thompsongl Mar 18, 2020
a1fde1f
beacon test
thompsongl Mar 18, 2020
224ca9a
tour_step_indicator test
thompsongl Mar 18, 2020
f4299e0
tour_step test
thompsongl Mar 18, 2020
e24f906
Merge branch 'master' into rk/505-euitour
thompsongl Mar 19, 2020
6ac82d9
beta label
thompsongl Mar 19, 2020
d0f94ea
change hasBeacon boolean prop to decoration enum prop
thompsongl Mar 19, 2020
2a1cf69
reducer guards
thompsongl Mar 19, 2020
d64e69c
Merge branch 'master' into rk/505-euitour
thompsongl Mar 19, 2020
d484a17
replaceable footer action
thompsongl Mar 19, 2020
7af1fd7
Merge branch 'master' into rk/505-euitour
thompsongl Mar 25, 2020
3f45c0a
Merge branch 'master' into rk/505-euitour
thompsongl Mar 26, 2020
7734089
docs updates
thompsongl Mar 26, 2020
429df67
src changes
thompsongl Mar 26, 2020
00c4f10
Merge branch 'master' into rk/505-euitour
thompsongl Mar 27, 2020
0885e8e
use GuideFullScreen
thompsongl Mar 27, 2020
28973de
beacon transition
thompsongl Mar 27, 2020
8a2d4b1
misc a11y
thompsongl Mar 27, 2020
4ce53d7
Merge branch 'master' into rk/505-euitour
thompsongl Mar 30, 2020
a4f1b21
step example
thompsongl Mar 30, 2020
c9e3744
Merge branch 'master' into rk/505-euitour
thompsongl Mar 30, 2020
b43d043
Merge branch 'master' into rk/505-euitour
thompsongl Mar 31, 2020
3f2becf
use new component name style
thompsongl Mar 31, 2020
a07696b
Merge branch 'master' into rk/505-euitour
thompsongl Mar 31, 2020
3764ec6
Merge branch 'master' into rk/505-euitour
thompsongl Apr 1, 2020
9e32bbd
docs clean up
thompsongl Apr 1, 2020
5e19c19
Update src-docs/src/views/tour/step.js
thompsongl Apr 1, 2020
bd9587e
Update src-docs/src/views/beacon/beacon_example.js
thompsongl Apr 1, 2020
53d53dd
Update src/components/tour/_tour.scss
thompsongl Apr 1, 2020
71ed1e7
Update src-docs/src/views/tour/step.js
thompsongl Apr 1, 2020
7cf9aff
Update src-docs/src/views/tour/tour_example.js
thompsongl Apr 1, 2020
88699d8
Update src-docs/src/views/tour/tour_example.js
thompsongl Apr 1, 2020
293bd6a
Update src-docs/src/views/tour/tour_example.js
thompsongl Apr 1, 2020
b9c7642
lint fixes
thompsongl Apr 1, 2020
6f51b83
misc formatting
thompsongl Apr 1, 2020
cf90dde
move interface
thompsongl Apr 1, 2020
86fb015
comments and tests
thompsongl Apr 1, 2020
341a359
start EuiTour example closed by default
thompsongl Apr 1, 2020
4ccb005
onFinish only
thompsongl Apr 2, 2020
cb318a9
handle one-step tours
thompsongl Apr 2, 2020
6b17460
clean up
thompsongl Apr 2, 2020
75c0d42
Merge branch 'master' into rk/505-euitour
thompsongl Apr 3, 2020
7b3ec39
docs updates
thompsongl Apr 3, 2020
964465a
popover tests
thompsongl Apr 3, 2020
a3dc4e1
docs update
thompsongl Apr 3, 2020
a5f6cf8
Merge branch 'master' into rk/505-euitour
thompsongl Apr 6, 2020
02e6951
update complete/incomplete logic
thompsongl Apr 6, 2020
11ef87f
Merge branch 'master' into rk/505-euitour
thompsongl Apr 7, 2020
71f31cb
misc feedback updates
thompsongl Apr 7, 2020
2b26855
tour reducer action types
thompsongl Apr 7, 2020
2e91eb2
Merge branch 'master' into rk/505-euitour
thompsongl Apr 7, 2020
8d846bf
1-based indexing
thompsongl Apr 7, 2020
b4bd1db
Merge branch 'master' into rk/505-euitour
thompsongl Apr 8, 2020
59a41d2
remove isTourActive from step api; docs clean up
thompsongl Apr 8, 2020
50170b8
add payload options for goto and finish
thompsongl Apr 8, 2020
87b96f5
Merge branch 'master' into rk/505-euitour
thompsongl Apr 9, 2020
25020b3
new badge
thompsongl Apr 9, 2020
eb4a77b
Merge branch 'master' into rk/505-euitour
thompsongl Apr 9, 2020
6519148
CL
thompsongl Apr 9, 2020
ac39673
Merge branch 'master' into rk/505-euitour
thompsongl Apr 13, 2020
480ead2
CL
thompsongl Apr 13, 2020
a301ff7
Merge branch 'master' into rk/505-euitour
thompsongl Apr 13, 2020
89a1394
Merge branch 'master' into rk/505-euitour
thompsongl Apr 14, 2020
d748e8d
Merge branch 'master' into rk/505-euitour
thompsongl Apr 14, 2020
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- Converted `NavDrawer`, `NavDrawerGroup`, and `NavDrawerFlyout` to TypeScript ([#3268](https://github.com/elastic/eui/pull/3268))
- Converted `EuiDatePicker`, `EuiDatePickerRange`, `EuiSuperDatePicker`, and `EuiSuperUpdateButton` to TypeScript ([#2891](https://github.com/elastic/eui/pull/2891))
- Improved condensed `EuiTabs` focus states ([#3299](https://github.com/elastic/eui/pull/3299))
- Added `EuiTour`, `EuiTourStep`, and `useEuiTour` components ([#2766](https://github.com/elastic/eui/pull/2766))
- Added `EuiBeacon` component ([#2766](https://github.com/elastic/eui/pull/2766))
- Added `offset` and `arrowChildren` props to `EuiPopover` for anchor element customization ([#2766](https://github.com/elastic/eui/pull/2766))

## [`22.5.0`](https://github.com/elastic/eui/tree/v22.5.0)

Expand Down
6 changes: 6 additions & 0 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import { AvatarExample } from './views/avatar/avatar_example';

import { BadgeExample } from './views/badge/badge_example';

import { BeaconExample } from './views/beacon/beacon_example';

import { BottomBarExample } from './views/bottom_bar/bottom_bar_example';

import { BreadcrumbsExample } from './views/breadcrumbs/breadcrumbs_example';
Expand Down Expand Up @@ -204,6 +206,8 @@ import { ToolTipExample } from './views/tool_tip/tool_tip_example';

import { ToggleExample } from './views/toggle/toggle_example';

import { TourExample } from './views/tour/tour_example';

import { WindowEventExample } from './views/window_event/window_event_example';

import { Changelog } from './views/package/changelog';
Expand Down Expand Up @@ -382,6 +386,7 @@ const navigation = [
TitleExample,
ToastExample,
ToolTipExample,
TourExample,
].map(example => createExample(example)),
},
{
Expand Down Expand Up @@ -418,6 +423,7 @@ const navigation = [
name: 'Utilities',
items: [
AccessibilityExample,
BeaconExample,
cchaos marked this conversation as resolved.
Show resolved Hide resolved
IsColorDarkExample,
ColorPaletteExample,
CopyExample,
Expand Down
11 changes: 10 additions & 1 deletion src-docs/src/services/full_screen/full_screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export const GuideFullScreen: FunctionComponent<{
children: (setFullScreen: (isFullScreen: boolean) => void) => ReactElement;
buttonText?: ReactNode;
isFullScreen?: boolean;
onOpen?: () => void;
}> = ({
children,
isFullScreen = false,
buttonText = 'Show fullscreen demo',
onOpen,
}) => {
const [fullScreen, setFullScreen] = useState(isFullScreen);

Expand All @@ -31,9 +33,16 @@ export const GuideFullScreen: FunctionComponent<{
};
}, [fullScreen]);

const openFullScreen = () => {
setFullScreen(true);
if (onOpen) {
onOpen();
}
};

return (
<Fragment>
<EuiButton onClick={() => setFullScreen(true)} iconType="fullScreen">
<EuiButton onClick={openFullScreen} iconType="fullScreen">
{buttonText}
</EuiButton>

Expand Down
1 change: 1 addition & 0 deletions src-docs/src/services/full_screen/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { GuideFullScreen } from './full_screen';
2 changes: 2 additions & 0 deletions src-docs/src/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export { translateUsingPseudoLocale } from './string/pseudo_locale_translator';
export { registerTheme, applyTheme } from './theme/theme';

export { getRouterLinkProps, registerRouter } from './routing/routing';

export { GuideFullScreen } from './full_screen';
9 changes: 9 additions & 0 deletions src-docs/src/views/beacon/beacon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

import { EuiBeacon } from '../../../../src/components';

export default () => (
<>
<EuiBeacon />
</>
);
39 changes: 39 additions & 0 deletions src-docs/src/views/beacon/beacon_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';

import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';

import { EuiBeacon, EuiText } from '../../../../src/components';

import Beacon from './beacon';
const beaconSource = require('!!raw-loader!./beacon');
const beaconHtml = renderToHtml(Beacon);

export const BeaconExample = {
title: 'Beacon',
sections: [
{
source: [
{
type: GuideSectionTypes.JS,
code: beaconSource,
},
{
type: GuideSectionTypes.HTML,
code: beaconHtml,
},
],
text: (
<EuiText>
<p>
Use the <strong>EuiBeacon</strong> component to draw visual
attention to a specific location or element.
</p>
</EuiText>
),
props: { EuiBeacon },
demo: <Beacon />,
},
],
};
238 changes: 238 additions & 0 deletions src-docs/src/views/tour/fullscreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
import React, { Fragment, useEffect, useState } from 'react';

import { GuideFullScreen } from '../../services';

import {
EuiButton,
EuiButtonEmpty,
EuiColorPicker,
EuiColorPickerSwatch,
EuiPage,
EuiPageBody,
EuiPageHeader,
EuiPageHeaderSection,
EuiPageContent,
EuiPageContentHeader,
EuiPageContentHeaderSection,
EuiPageContentBody,
EuiSpacer,
EuiStat,
EuiTab,
EuiTabs,
EuiTextArea,
EuiTitle,
EuiTourStep,
useEuiTour,
} from '../../../../src/components';

const demoTourSteps = [
{
step: 1,
title: 'Step 1',
},
{
step: 2,
title: 'Step 2',
anchorPosition: 'upCenter',
content: <p>What is your favorite color?</p>,
},
{
step: 3,
title: 'Step 3',
content: <p>Click here for more cool things.</p>,
anchorPosition: 'downRight',
minWidth: 'auto',
},
{
step: 4,
title: 'Step 4',
anchorPosition: 'downLeft',
decoration: 'none',
},
];

const tourConfig = {
currentTourStep: 1,
isTourActive: true,
tourPopoverWidth: true,
tourSubtitle: 'Demo tour',
};

export default () => {
const [color, setColor] = useState('#000');
const [selectedTabId, setSelectedTabId] = useState('query');
const [
[euiTourStepOne, euiTourStepTwo, euiTourStepThree, euiTourStepFour],
actions,
reducerState,
] = useEuiTour(demoTourSteps, tourConfig);

useEffect(() => {
console.log('Update', reducerState);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thompsongl was it intentional to leave these console.log statements in here (there are two more that start with 'Updating localstorage')? I found it strange/surprising that it logs on production (well, on the EUI docs site, haha).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha nope. We should remove these.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

luckily, I made the branch that fixes this last night :) #3513

}, [reducerState]);

const onSelectColor = color => {
setColor(color);
if (reducerState.currentTourStep === 2) {
actions.goToStep(3);
}
};

const onTabClick = id => {
if (id === 'stat' && reducerState.currentTourStep === 3) {
actions.goToStep(4);
}
setSelectedTabId(id);
};

const onReset = () => {
actions.resetTour();
setSelectedTabId('query');
};

const tabs = [
{
id: 'query',
name: 'Query',
disabled: false,
content: (
<div>
<EuiSpacer />
<EuiTourStep
thompsongl marked this conversation as resolved.
Show resolved Hide resolved
{...euiTourStepOne}
content={
<div>
<p>This is a neat thing. You enter queries here.</p>
<EuiSpacer />
<EuiButton color="primary" onClick={actions.incrementStep}>
Ok, got it.
</EuiButton>
</div>
}>
<EuiTextArea
placeholder="Placeholder text"
aria-label="Enter ES SQL query"
defaultValue="{queryValue}"
style={{ width: 400 }}
/>
</EuiTourStep>

<EuiSpacer />

<EuiTourStep
{...euiTourStepTwo}
footerAction={
<EuiButtonEmpty
color="text"
flush="right"
size="xs"
onClick={actions.incrementStep}>
{"I don't have a favorite color"}
</EuiButtonEmpty>
}>
<EuiColorPicker
onChange={onSelectColor}
color={color}
mode="swatch"
button={
<EuiColorPickerSwatch
color={color}
aria-label="Select a color"
/>
}
/>
</EuiTourStep>
</div>
),
},
{
id: 'stat',
name: (
<EuiTourStep {...euiTourStepThree}>
<span>Stats</span>
</EuiTourStep>
),
disabled: false,
content: (
<div>
<EuiSpacer />
<EuiTourStep
thompsongl marked this conversation as resolved.
Show resolved Hide resolved
{...euiTourStepFour}
content={
<div>
<p>That about does it.</p>
<EuiSpacer />
<EuiButton color="primary" onClick={onReset}>
Take me to the start.
</EuiButton>
</div>
}>
<div>
<EuiStat title="22,123" description="Queries" />
</div>
</EuiTourStep>
</div>
),
},
];

return (
<GuideFullScreen onOpen={onReset}>
{setIsFullScreen => (
<React.Fragment>
<EuiPage className="guideFullScreenOverlay" style={{ zIndex: 9000 }}>
<EuiPageBody>
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>My app</h1>
</EuiTitle>
</EuiPageHeaderSection>
<EuiPageHeaderSection>
<EuiButton
fill
onClick={() => setIsFullScreen(false)}
iconType="exit"
aria-label="Exit fullscreen demo">
Exit fullscreen demo
</EuiButton>
</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageContent>
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
<EuiTitle>
<h2>A new feature to demo</h2>
</EuiTitle>
</EuiPageContentHeaderSection>
</EuiPageContentHeader>
<EuiPageContentBody>
<EuiTabs>
{tabs.map((tab, index) => (
<EuiTab
id={tab.id}
onClick={() => onTabClick(tab.id)}
isSelected={tab.id === selectedTabId}
key={index}>
{tab.name}
</EuiTab>
))}
</EuiTabs>
{tabs.map((tab, index) => (
<Fragment key={index}>
{tab.id === selectedTabId && (
<div role="tabpanel" aria-labelledby={tab.id}>
{tab.content}
</div>
)}
</Fragment>
))}
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
</EuiPage>
</React.Fragment>
)}
</GuideFullScreen>
);
};
Loading