Skip to content

Commit bc94c3f

Browse files
committed
Improve component docs and styles
1 parent 0043bb1 commit bc94c3f

File tree

5 files changed

+74
-18
lines changed

5 files changed

+74
-18
lines changed

lib/ContextMenuWrapper.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
11
import React from 'react';
22
import { ContextMenuEvent } from './handlers';
33
export interface ContextMenuWrapperProps {
4+
/**
5+
* A unique ID that will be used to trigger this context menu from other components on the page. Global menus don't
6+
* use IDs.
7+
*/
48
id?: string;
9+
/**
10+
* Determines whether this context menu should replace the default context meu of your browser.
11+
* If this is set, `id` is ignored.
12+
*/
513
global?: boolean;
614
children?: React.ReactElement;
15+
/**
16+
* Callback that is triggered after the menu has appeared.
17+
*/
718
onShow?: (event: ContextMenuEvent) => void;
19+
/**
20+
* Callback that is triggered after the menu has been dismissed.
21+
*/
822
onHide?: () => void;
23+
/**
24+
* Makes context menu disappear when user clicks (or taps) anywhere inside of the menu.
25+
*/
926
hideOnSelfClick?: boolean;
27+
/**
28+
* Makes context menu disappear when user clicks (or taps) anywhere outside of the menu.
29+
*/
1030
hideOnOutsideClick?: boolean;
31+
/**
32+
* Makes context menu disappear when user presses the Escape key.
33+
*/
1134
hideOnEscape?: boolean;
35+
/**
36+
* Makes context menu disappear when page is scrolled.
37+
*/
1238
hideOnScroll?: boolean;
39+
/**
40+
* Makes context menu disappear when window is resized.
41+
*/
1342
hideOnWindowResize?: boolean;
1443
}
1544
export declare const ContextMenuWrapper: React.FC<ContextMenuWrapperProps>;

lib/ContextMenuWrapper.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ContextMenuWrapper.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,47 @@ import { ContextMenuEvent } from './handlers';
55
import { ContextMenuEventContext, useInternalHandlers, useMenuPlacementStyle, useMenuToggleMethods } from './hooks';
66

77
export interface ContextMenuWrapperProps {
8+
/**
9+
* A unique ID that will be used to trigger this context menu from other components on the page. Global menus don't
10+
* use IDs.
11+
*/
812
id?: string;
13+
/**
14+
* Determines whether this context menu should replace the default context meu of your browser.
15+
* If this is set, `id` is ignored.
16+
*/
917
global?: boolean;
1018
children?: React.ReactElement;
1119

20+
/**
21+
* Callback that is triggered after the menu has appeared.
22+
*/
1223
onShow?: (event: ContextMenuEvent) => void;
24+
/**
25+
* Callback that is triggered after the menu has been dismissed.
26+
*/
1327
onHide?: () => void;
1428

29+
/**
30+
* Makes context menu disappear when user clicks (or taps) anywhere inside of the menu.
31+
*/
1532
hideOnSelfClick?: boolean;
33+
/**
34+
* Makes context menu disappear when user clicks (or taps) anywhere outside of the menu.
35+
*/
1636
hideOnOutsideClick?: boolean;
1737

38+
/**
39+
* Makes context menu disappear when user presses the Escape key.
40+
*/
1841
hideOnEscape?: boolean;
42+
/**
43+
* Makes context menu disappear when page is scrolled.
44+
*/
1945
hideOnScroll?: boolean;
46+
/**
47+
* Makes context menu disappear when window is resized.
48+
*/
2049
hideOnWindowResize?: boolean;
2150
}
2251

styleguide.config.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,20 @@ module.exports = {
5656
sortProps: props => props,
5757
propsParser: (filePath, source, resolver, handlers) => {
5858
const result = require('react-docgen-typescript')
59-
.withCustomConfig('./tsconfig.json')
59+
.withCustomConfig('./tsconfig.json', { savePropValueAsString: true })
6060
.parse(filePath, source, resolver, handlers);
6161

6262
return result.map(component => {
6363
const { props } = component;
6464
const mappedProps = Object.values(props).reduce((previous, prop) => {
6565
const { name, type } = prop;
6666
if (type.name.includes('| undefined')) {
67-
type.name = type.name.replace('| undefined', '');
67+
type.name = type.name.replace('| undefined', '').trim();
6868
if (!prop.defaultValue) prop.defaultValue = { value: 'null' };
6969
if (type.name.startsWith('(') && type.name.endsWith(')')) {
70-
type.name = type.name.slice(1, type.name.length - 2);
70+
type.name = type.name.slice(1, type.name.length - 1);
7171
}
7272
}
73-
if (prop.defaultValue && prop.defaultValue.value.charAt(0) === '{') {
74-
let value = prop.defaultValue.value;
75-
value = value.replace(/(\n)+/g, '&');
76-
value = value.replace(/(\s)+/g, '|');
77-
value = value.replace(/:\|/g, ': ');
78-
value = value.replace(/&\|}/g, '\n}');
79-
value = value.replace(/&\|/g, '\n ');
80-
prop.defaultValue.value = value;
81-
}
8273

8374
return { ...previous, [name]: { ...prop } };
8475
}, {});

styleguide.css

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,32 +97,39 @@ div[class*='--preview-'] {
9797
}
9898

9999
.banner {
100+
box-shadow: inset rgba(0, 0, 0, 0.1) 0 0 0 1px;
100101
background-color: #a3eee3;
102+
border-radius: 5px;
101103
line-height: 100px;
102104
text-align: center;
103-
font-size: 1.4rem;
105+
font-size: 1.3rem;
104106
color: #446156;
105107
}
106108

107109
.box-container {
108110
flex-direction: row;
109-
margin: 0 -10px;
110111
display: flex;
112+
margin: -5px;
111113
}
112114

113115
.box {
116+
box-shadow: inset rgba(0, 0, 0, 0.1) 0 0 0 1px;
114117
background-color: #ffb7c6;
115-
border: solid 1px #aaa;
116118
border-radius: 5px;
117119
text-align: center;
118120
line-height: 60px;
119-
margin: 0 10px;
120121
color: #6c1426;
122+
margin: 5px;
121123
flex: 1 1 0;
122124
}
123125

126+
@media screen and (max-width: 400px) {
127+
.box-container {
128+
flex-direction: column;
129+
}
130+
}
131+
124132
.box-active {
125133
background-color: #a3eee3;
126-
border: solid 1px #007d6a;
127134
color: #007d6a;
128135
}

0 commit comments

Comments
 (0)