Skip to content

Commit 14e6f02

Browse files
authored
New link popup icons (#160)
1 parent c2e2958 commit 14e6f02

File tree

13 files changed

+11983
-110
lines changed

13 files changed

+11983
-110
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@babel/preset-env": "^7.4.5",
4040
"@babel/preset-react": "^7.0.0",
4141
"@rollup/plugin-json": "4.0.1",
42+
"@svgr/rollup": "^5.5.0",
4243
"@types/prosemirror-model": "^1.7.2",
4344
"@types/prosemirror-view": "^1.11.4",
4445
"@types/react": "^16.9.29",

packages/core/src/plugins/link/popups/Create.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import * as React from 'react';
1+
import * as React from "react";
22
import {
33
ChangeEvent,
44
FunctionComponent,
55
MutableRefObject,
66
useState,
7-
} from 'react';
8-
import styled from '@emotion/styled';
9-
import { EditorState } from 'prosemirror-state';
7+
} from "react";
8+
import styled from "@emotion/styled";
9+
import { EditorState } from "prosemirror-state";
1010

11-
import { PrimaryButton, Input, Popup } from 'nib-ui';
11+
import { ToolbarButton, Input, Popup, Icon } from "nib-ui";
1212

13-
import { EditorStyle } from '../../../types/editor-style';
14-
import { usePMStateContext } from '../../../context/pm-state/index';
15-
import { linkPluginKey } from '../plugin';
13+
import { EditorStyle } from "../../../types/editor-style";
14+
import { usePMStateContext } from "../../../context/pm-state/index";
15+
import { linkPluginKey } from "../plugin";
1616

1717
interface CreatePopupProps {
1818
editorWrapper: MutableRefObject<HTMLDivElement | null>;
@@ -36,7 +36,7 @@ const CreatePopup: FunctionComponent<CreatePopupProps> = ({
3636
};
3737

3838
const [linkText, setLinkText] = useState(getSelectedText());
39-
const [href, setHref] = useState('');
39+
const [href, setHref] = useState("");
4040
const [linkTextRequiredError, setLinkTextRequiredError] = useState(false);
4141

4242
const updateLinkText = (evt: ChangeEvent) => {
@@ -58,7 +58,7 @@ const CreatePopup: FunctionComponent<CreatePopupProps> = ({
5858
const { $from, $to } = selection;
5959
dispatch(
6060
tr
61-
.setMeta('show-add-link-toolbar', false)
61+
.setMeta("show-add-link-toolbar", false)
6262
.insertText(linkText, $from.pos, $to.pos)
6363
.addMark(
6464
$from.pos,
@@ -71,14 +71,14 @@ const CreatePopup: FunctionComponent<CreatePopupProps> = ({
7171
};
7272

7373
const handleKeyDown = (evt: KeyboardEvent) => {
74-
if (evt.key === 'Enter') {
74+
if (evt.key === "Enter") {
7575
addLink();
7676
}
7777
};
7878

7979
const closePopup = () => {
8080
const { state, dispatch } = pmview;
81-
dispatch(state.tr.setMeta('show-add-link-toolbar', false));
81+
dispatch(state.tr.setMeta("show-add-link-toolbar", false));
8282
};
8383

8484
return (
@@ -111,21 +111,23 @@ const CreatePopup: FunctionComponent<CreatePopupProps> = ({
111111
value={href}
112112
/>
113113
</InputWrapper>
114-
<PrimaryButton onKeyPress={handleKeyDown} onClick={addLink}>
115-
Add
116-
</PrimaryButton>
117-
<PrimaryButton onClick={closePopup}>Cancel</PrimaryButton>
114+
<ToolbarButton onKeyPress={handleKeyDown} onClick={addLink}>
115+
<Icon name="check" />
116+
</ToolbarButton>
117+
<ToolbarButton onClick={closePopup}>
118+
<Icon name="closeNew" />
119+
</ToolbarButton>
118120
</Wrapper>
119121
)}
120122
/>
121123
);
122124
};
123125

124126
export default {
125-
name: 'create_link',
127+
name: "create_link",
126128
getMarker: (editorWrapper: MutableRefObject<HTMLDivElement | null>) =>
127129
editorWrapper.current &&
128-
editorWrapper.current.getElementsByClassName('nib-link-marker')[0],
130+
editorWrapper.current.getElementsByClassName("nib-link-marker")[0],
129131
condition: ({ state }: { state: EditorState }) => {
130132
const pluginState = linkPluginKey.getState(state);
131133
return pluginState && pluginState.showAddLinkToolbar;
@@ -144,7 +146,7 @@ const Wrapper = styled.div`
144146
`;
145147

146148
const InputWrapper = styled.div({
147-
'> div:first-of-type': {
149+
"> div:first-of-type": {
148150
marginBottom: 8,
149151
},
150152
});

packages/core/src/plugins/link/popups/Edit.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import * as React from 'react';
1+
import * as React from "react";
22
import {
33
ChangeEvent,
44
FunctionComponent,
55
MutableRefObject,
66
useState,
7-
} from 'react';
8-
import styled from '@emotion/styled';
9-
import { TextSelection } from 'prosemirror-state';
7+
} from "react";
8+
import styled from "@emotion/styled";
9+
import { TextSelection } from "prosemirror-state";
1010

11-
import { PrimaryButton, Input, Popup, Space, SpaceSize } from 'nib-ui';
11+
import { ToolbarButton, Input, Popup, Icon } from "nib-ui";
1212

13-
import { EditorStyle } from '../../../types/editor-style';
14-
import { usePMStateContext } from '../../../context/pm-state/index';
15-
import { linkPluginKey } from '../plugin';
13+
import { EditorStyle } from "../../../types/editor-style";
14+
import { usePMStateContext } from "../../../context/pm-state/index";
15+
import { linkPluginKey } from "../plugin";
1616

1717
export interface EditPopupProps {
1818
editorWrapper: MutableRefObject<HTMLDivElement | null>;
@@ -62,7 +62,7 @@ const EditPopup: FunctionComponent<EditPopupProps> = ({
6262

6363
const closePopup = () => {
6464
const { state, dispatch } = pmview;
65-
dispatch(state.tr.setMeta('show-edit-link-toolbar', false));
65+
dispatch(state.tr.setMeta("show-edit-link-toolbar", false));
6666
};
6767

6868
return (
@@ -81,20 +81,23 @@ const EditPopup: FunctionComponent<EditPopupProps> = ({
8181
}
8282
defaultValue={link.href}
8383
/>
84-
<PrimaryButton onClick={updateLink}>Update</PrimaryButton>
85-
<Space size={SpaceSize.l} />
86-
<PrimaryButton onClick={unLink}>Unlink</PrimaryButton>
84+
<ToolbarButton onClick={updateLink}>
85+
<Icon name="check" />
86+
</ToolbarButton>
87+
<ToolbarButton onClick={unLink}>
88+
<Icon name="linkOff" />
89+
</ToolbarButton>
8790
</Wrapper>
8891
)}
8992
/>
9093
);
9194
};
9295

9396
export default {
94-
name: 'edit_link',
97+
name: "edit_link",
9598
getMarker: (editorWrapper: MutableRefObject<HTMLDivElement | null>) =>
9699
editorWrapper.current &&
97-
editorWrapper.current.getElementsByClassName('nib-edit-link-marker')[0],
100+
editorWrapper.current.getElementsByClassName("nib-edit-link-marker")[0],
98101
component: EditPopup,
99102
};
100103

packages/docs/styleguide/Logo.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import React from "react";
22
import PropTypes from "prop-types";
33
import Styled from "rsg-components/Styled";
4-
import pen from "./pen.svg";
4+
import Pen from "./pen.svg";
55

66
const styles = ({ fontFamily, color }) => ({
77
logo: {
88
margin: 0,
99
fontFamily: fontFamily.base,
1010
fontSize: 18,
1111
fontWeight: "normal",
12-
color: color.baseBackground
12+
color: color.baseBackground,
1313
},
1414
image: {
1515
width: "2.5em",
16-
marginRight: 25
16+
marginRight: 25,
1717
},
1818
link: {
1919
display: "flex",
2020
alignItems: "center",
21-
cursor: "pointer"
22-
}
21+
cursor: "pointer",
22+
},
2323
});
2424
export function LogoRenderer({ classes }) {
2525
return (
2626
<h1 className={classes.logo}>
2727
<a className={classes.link} href="">
28-
<img className={classes.image} src={pen} />
28+
{/* <Pen className={classes.image} /> */}
2929
<span style={{ fontSize: 24, marginLeft: 8 }}>Nib</span>
3030
</a>
3131
</h1>
@@ -34,7 +34,7 @@ export function LogoRenderer({ classes }) {
3434

3535
LogoRenderer.propTypes = {
3636
classes: PropTypes.object.isRequired,
37-
children: PropTypes.node
37+
children: PropTypes.node,
3838
};
3939

4040
export default Styled(styles)(LogoRenderer);

packages/ui/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
"author": "Jyoti Puri",
1515
"homepage": "https://github.com/jpuri/Nib/tree/master/packages/ui/#Readme.md",
1616
"devDependencies": {
17-
"react": "next",
18-
"react-dom": "next",
17+
"@svgr/webpack": "^5.5.0",
1918
"emotion-theming": "^10.0.14",
20-
"prop-types": "^15.6.2"
19+
"prop-types": "^15.6.2",
20+
"react": "next",
21+
"react-dom": "next"
2122
},
2223
"license": "MIT"
2324
}

packages/ui/src/icons/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ import Video from "./Video";
4444
import ViewComment from "./ViewComment";
4545
import WrapLeft from "./WrapLeft";
4646
import WrapRight from "./WrapRight";
47+
import Check from "./svg/check.svg";
48+
import CloseNew from "./svg/close.svg";
49+
import LinkOff from "./svg/link_off.svg";
4750

4851
export default {
4952
add: Add,
@@ -92,4 +95,7 @@ export default {
9295
viewComment: ViewComment,
9396
wrapLeft: WrapLeft,
9497
wrapRight: WrapRight,
98+
closeNew: CloseNew,
99+
check: Check,
100+
linkOff: LinkOff,
95101
};

packages/ui/src/icons/svg/check.svg

Lines changed: 1 addition & 0 deletions
Loading

packages/ui/src/icons/svg/close.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)