@atlaskit/spotlight 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/spotlight
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`2a1e06ea7c3d7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a1e06ea7c3d7) -
8
+ Expose `offset` prop on `PopoverContent`. `PopoverContent` can now be manually positioned anywhere
9
+ within the viewport.
10
+
11
+ ## 0.7.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [`ccbe07df5c620`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ccbe07df5c620) -
16
+ Update documentation to include motion example.
17
+
3
18
  ## 0.7.1
4
19
 
5
20
  ### Patch Changes
@@ -7,6 +7,7 @@ import SingleStepExample from '../../examples/constellation/single-step';
7
7
  import MultipleStepsExample from '../../examples/constellation/multiple-steps';
8
8
  import MediaExample from '../../examples/constellation/media';
9
9
  import ControlsExample from '../../examples/constellation/controls';
10
+ import MotionExample from '../../examples/constellation/motion';
10
11
 
11
12
  ## Single step
12
13
 
@@ -20,16 +21,16 @@ To show/hide the `SpotlightCard`, simply use a `useState` to control the `isVisi
20
21
  `PopoverContent`. To position the `SpotlightCard`, use `PopoverProvider`, `PopoverTarget` and
21
22
  `PopoverContent` and set the `placement` prop.
22
23
 
23
- <Example Component={SingleStepExample} packageName="@atlaskit/spinner" />
24
+ <Example Component={SingleStepExample} packageName="@atlaskit/spotlight" />
24
25
 
25
26
  ## Multi-step tour
26
27
 
27
- Multiple steps should be avoided if possible. If multiple steps are required, preference managing
28
- the tour with a `useState`. If `useState` is not feasible, then a React context may be used.
29
- However, these contexts will often need to be wrapping the entire `App` and therefore will cause the
30
- entire `App` to re-render every time a new spotlight step is shown, which is not performant.
28
+ Multiple steps should be avoided if possible, but if they are required, manage the tour with a
29
+ `useState`. If `useState` is not feasible, then a React context may be used. However, these contexts
30
+ will often need to be wrapping the entire `App` and therefore will cause the entire `App` to
31
+ re-render every time a new spotlight step is shown.
31
32
 
32
- <Example Component={MultipleStepsExample} packageName="@atlaskit/spinner" />
33
+ <Example Component={MultipleStepsExample} packageName="@atlaskit/spotlight" />
33
34
 
34
35
  ## Placements
35
36
 
@@ -37,7 +38,7 @@ Spotlight placements are static. They do not change as the user scrolls, or if t
37
38
  overflows out of the viewport. Make sure to choose a placement that ensures the `SpotlightCard` is
38
39
  displayed in full.
39
40
 
40
- <Example Component={PlacementsExample} packageName="@atlaskit/spinner" />
41
+ <Example Component={PlacementsExample} packageName="@atlaskit/spotlight" />
41
42
 
42
43
  ## Media
43
44
 
@@ -46,9 +47,16 @@ correct reflow on smaller viewports, media must be 295px width X 135px height.
46
47
 
47
48
  Media can be an image, gif, or video that helps communicate spotlight intent.
48
49
 
49
- <Example Component={MediaExample} packageName="@atlaskit/spinner" />
50
+ <Example Component={MediaExample} packageName="@atlaskit/spotlight" />
50
51
 
51
52
  ## Controls
52
53
 
53
54
  `SpotlightDismissControl` is required for all `SpotlightCard` components. It **must** be the first
54
55
  focusable element on the `SpotlightCard` card to provide an accessible experience.
56
+
57
+ ## Motion
58
+
59
+ `@atlaskit/spotlight` can be composed with `@atlaskit/motion` or other CSS animation packages to
60
+ create smooth 'enter' or 'exit' transitions.
61
+
62
+ <Example Component={MotionExample} packageName="@atlaskit/spotlight" />
@@ -34,9 +34,7 @@ var SpotlightDismissControl = exports.SpotlightDismissControl = /*#__PURE__*/(0,
34
34
  var dismiss = function dismiss(event) {
35
35
  popoverContent.dismiss.current(event);
36
36
  };
37
- return /*#__PURE__*/React.createElement(_compiled.Pressable
38
- // eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
39
- , {
37
+ return /*#__PURE__*/React.createElement(_compiled.Pressable, {
40
38
  autoFocus: autoFocus,
41
39
  onClick: onClick || dismiss,
42
40
  ref: ref,
@@ -22,6 +22,10 @@ var styles = {
22
22
  root: "_1pby1fw0"
23
23
  };
24
24
 
25
+ /**
26
+ * Taken from `@atlaskit/popper`
27
+ */
28
+
25
29
  /**
26
30
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
27
31
  * the caret extending beyond the bounding box (by roughly 2px). So, apply an offset to ensure
@@ -30,7 +34,7 @@ var styles = {
30
34
  * Note: `@atlaskit/popper` maps the offset to the placement, so we only need to define `[0, 2]` and
31
35
  * the offset will get correctly rotated depending on the placement.
32
36
  */
33
- var offset = [0, 2];
37
+ var defaultOffset = [0, 2];
34
38
  /**
35
39
  * The Spotlight card can be positioned in many different configurations, but the caret should always point to
36
40
  * the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
@@ -64,7 +68,9 @@ var PopoverContent = exports.PopoverContent = function PopoverContent(props) {
64
68
  shouldDismissOnClickOutside = _props$shouldDismissO === void 0 ? true : _props$shouldDismissO,
65
69
  dismiss = props.dismiss,
66
70
  back = props.back,
67
- testId = props.testId;
71
+ testId = props.testId,
72
+ _props$offset = props.offset,
73
+ offset = _props$offset === void 0 ? defaultOffset : _props$offset;
68
74
 
69
75
  /**
70
76
  * A user should only be able to pass a `done` or a `next`. Not both.
@@ -26,9 +26,7 @@ export const SpotlightDismissControl = /*#__PURE__*/forwardRef(({
26
26
  const dismiss = event => {
27
27
  popoverContent.dismiss.current(event);
28
28
  };
29
- return /*#__PURE__*/React.createElement(Pressable
30
- // eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
31
- , {
29
+ return /*#__PURE__*/React.createElement(Pressable, {
32
30
  autoFocus: autoFocus,
33
31
  onClick: onClick || dismiss,
34
32
  ref: ref,
@@ -13,6 +13,10 @@ const styles = {
13
13
  root: "_1pby1fw0"
14
14
  };
15
15
 
16
+ /**
17
+ * Taken from `@atlaskit/popper`
18
+ */
19
+
16
20
  /**
17
21
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
18
22
  * the caret extending beyond the bounding box (by roughly 2px). So, apply an offset to ensure
@@ -21,7 +25,7 @@ const styles = {
21
25
  * Note: `@atlaskit/popper` maps the offset to the placement, so we only need to define `[0, 2]` and
22
26
  * the offset will get correctly rotated depending on the placement.
23
27
  */
24
- const offset = [0, 2];
28
+ const defaultOffset = [0, 2];
25
29
  /**
26
30
  * The Spotlight card can be positioned in many different configurations, but the caret should always point to
27
31
  * the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
@@ -54,7 +58,8 @@ export const PopoverContent = props => {
54
58
  shouldDismissOnClickOutside = true,
55
59
  dismiss,
56
60
  back,
57
- testId
61
+ testId,
62
+ offset = defaultOffset
58
63
  } = props;
59
64
 
60
65
  /**
@@ -25,9 +25,7 @@ export var SpotlightDismissControl = /*#__PURE__*/forwardRef(function (_ref, ref
25
25
  var dismiss = function dismiss(event) {
26
26
  popoverContent.dismiss.current(event);
27
27
  };
28
- return /*#__PURE__*/React.createElement(Pressable
29
- // eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
30
- , {
28
+ return /*#__PURE__*/React.createElement(Pressable, {
31
29
  autoFocus: autoFocus,
32
30
  onClick: onClick || dismiss,
33
31
  ref: ref,
@@ -13,6 +13,10 @@ var styles = {
13
13
  root: "_1pby1fw0"
14
14
  };
15
15
 
16
+ /**
17
+ * Taken from `@atlaskit/popper`
18
+ */
19
+
16
20
  /**
17
21
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
18
22
  * the caret extending beyond the bounding box (by roughly 2px). So, apply an offset to ensure
@@ -21,7 +25,7 @@ var styles = {
21
25
  * Note: `@atlaskit/popper` maps the offset to the placement, so we only need to define `[0, 2]` and
22
26
  * the offset will get correctly rotated depending on the placement.
23
27
  */
24
- var offset = [0, 2];
28
+ var defaultOffset = [0, 2];
25
29
  /**
26
30
  * The Spotlight card can be positioned in many different configurations, but the caret should always point to
27
31
  * the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
@@ -55,7 +59,9 @@ export var PopoverContent = function PopoverContent(props) {
55
59
  shouldDismissOnClickOutside = _props$shouldDismissO === void 0 ? true : _props$shouldDismissO,
56
60
  dismiss = props.dismiss,
57
61
  back = props.back,
58
- testId = props.testId;
62
+ testId = props.testId,
63
+ _props$offset = props.offset,
64
+ offset = _props$offset === void 0 ? defaultOffset : _props$offset;
59
65
 
60
66
  /**
61
67
  * A user should only be able to pass a `done` or a `next`. Not both.
@@ -4,6 +4,10 @@
4
4
  */
5
5
  import { type ReactNode } from 'react';
6
6
  import type { BackEvent, DismissEvent, DoneEvent, NextEvent, Placement } from '../../types';
7
+ /**
8
+ * Taken from `@atlaskit/popper`
9
+ */
10
+ type Offset = [number | null | undefined, number | null | undefined];
7
11
  interface BasePopoverContentProps {
8
12
  /**
9
13
  * A `testId` prop is provided for specified elements, which is a unique
@@ -24,20 +28,26 @@ interface BasePopoverContentProps {
24
28
  */
25
29
  shouldDismissOnClickOutside?: boolean;
26
30
  /**
27
- * Spotlights can be dismissed by:
28
- * - Clicking the `SpotlightDismissControl`
29
- * - Clicking any DOM element outside the spotlight (if `shouldDismissOnClickOutside === true`)
30
- * - Pressing the Escape key
31
- *
32
- * These events align to the React.MouseEvent<HTMLButtonElement, MouseEvent>, MouseEvent, and KeyboardEvent events respectively.
33
- * Defaults to `true`.
31
+ * Spotlights can be dismissed by:
32
+ * - Clicking the `SpotlightDismissControl`
33
+ * - Clicking any DOM element outside the spotlight (if `shouldDismissOnClickOutside === true`)
34
+ * - Pressing the Escape key
35
+ *
36
+ * These events align to the React.MouseEvent<HTMLButtonElement, MouseEvent>, MouseEvent, and KeyboardEvent events respectively.
37
+ * Defaults to `true`.
34
38
  */
35
39
  dismiss: (event: DismissEvent) => void;
36
40
  /**
37
41
  * Invoked when the user clicks `SpotlightSecondaryAction`. If an `onClick` handler is provided to `SpotlightSecondaryAction`
38
42
  * then that takes precedence, and `back` will be ignored.
39
- */
43
+ */
40
44
  back?: (event: BackEvent) => void;
45
+ /**
46
+ * Distance the spotlight should be offset from the target in the format of [along, away] (units in px).
47
+ * Defaults to [0, 2] - which means the spotlight will be 2px away from the edge of the target specified
48
+ * by the `placement` prop.
49
+ */
50
+ offset?: Offset;
41
51
  /**
42
52
  * The content to be rendered in `PopoverContent`. This is intended to be a `SpotlightCard`.
43
53
  */
@@ -4,6 +4,13 @@
4
4
  */
5
5
  import { type ReactNode } from 'react';
6
6
  import type { BackEvent, DismissEvent, DoneEvent, NextEvent, Placement } from '../../types';
7
+ /**
8
+ * Taken from `@atlaskit/popper`
9
+ */
10
+ type Offset = [
11
+ number | null | undefined,
12
+ number | null | undefined
13
+ ];
7
14
  interface BasePopoverContentProps {
8
15
  /**
9
16
  * A `testId` prop is provided for specified elements, which is a unique
@@ -24,20 +31,26 @@ interface BasePopoverContentProps {
24
31
  */
25
32
  shouldDismissOnClickOutside?: boolean;
26
33
  /**
27
- * Spotlights can be dismissed by:
28
- * - Clicking the `SpotlightDismissControl`
29
- * - Clicking any DOM element outside the spotlight (if `shouldDismissOnClickOutside === true`)
30
- * - Pressing the Escape key
31
- *
32
- * These events align to the React.MouseEvent<HTMLButtonElement, MouseEvent>, MouseEvent, and KeyboardEvent events respectively.
33
- * Defaults to `true`.
34
+ * Spotlights can be dismissed by:
35
+ * - Clicking the `SpotlightDismissControl`
36
+ * - Clicking any DOM element outside the spotlight (if `shouldDismissOnClickOutside === true`)
37
+ * - Pressing the Escape key
38
+ *
39
+ * These events align to the React.MouseEvent<HTMLButtonElement, MouseEvent>, MouseEvent, and KeyboardEvent events respectively.
40
+ * Defaults to `true`.
34
41
  */
35
42
  dismiss: (event: DismissEvent) => void;
36
43
  /**
37
44
  * Invoked when the user clicks `SpotlightSecondaryAction`. If an `onClick` handler is provided to `SpotlightSecondaryAction`
38
45
  * then that takes precedence, and `back` will be ignored.
39
- */
46
+ */
40
47
  back?: (event: BackEvent) => void;
48
+ /**
49
+ * Distance the spotlight should be offset from the target in the format of [along, away] (units in px).
50
+ * Defaults to [0, 2] - which means the spotlight will be 2px away from the edge of the target specified
51
+ * by the `placement` prop.
52
+ */
53
+ offset?: Offset;
41
54
  /**
42
55
  * The content to be rendered in `PopoverContent`. This is intended to be a `SpotlightCard`.
43
56
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/spotlight",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "A spotlight introduces users to points of interest, from focused messages to multi-step tours.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,13 +35,13 @@
35
35
  "@atlaskit/browser-apis": "^0.0.1",
36
36
  "@atlaskit/button": "^23.5.0",
37
37
  "@atlaskit/css": "^0.15.0",
38
- "@atlaskit/ds-lib": "^5.1.0",
38
+ "@atlaskit/ds-lib": "^5.2.0",
39
39
  "@atlaskit/heading": "^5.2.0",
40
40
  "@atlaskit/icon": "^28.5.0",
41
41
  "@atlaskit/image": "^3.0.0",
42
42
  "@atlaskit/popper": "^7.1.0",
43
- "@atlaskit/primitives": "^16.0.0",
44
- "@atlaskit/tokens": "^7.0.0",
43
+ "@atlaskit/primitives": "^16.1.0",
44
+ "@atlaskit/tokens": "^7.1.0",
45
45
  "@atlaskit/visually-hidden": "^3.0.0",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "@compiled/react": "^0.18.6",