Skip to content

Commit 62c3fb3

Browse files
committed
Merge branch 'master' of https://github.com/microsoft/pxt into srietkerk/fullscreen-arrows
2 parents 5b31769 + cd8d1a8 commit 62c3fb3

File tree

6 files changed

+288
-21
lines changed

6 files changed

+288
-21
lines changed

localtypings/pxtarget.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ declare namespace pxt {
539539
pxtJsonOptions?: PxtJsonOption[];
540540
enabledFeatures?: pxt.Map<FeatureFlag>;
541541
forceEnableAiErrorHelp?: boolean; // Enables the AI Error Help feature, regardless of geo setting.
542+
shareHomepageContent?: boolean; // Show buttons to share links to homepage content more easily
542543
}
543544

544545
interface DownloadDialogTheme {
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import * as React from "react";
2+
3+
import { Modal } from "../controls/Modal";
4+
import { Input } from "../controls/Input";
5+
import { Button } from "../controls/Button";
6+
7+
export interface ShareLinkDialogProps {
8+
visible: boolean;
9+
shareUrl?: string;
10+
title?: string;
11+
ariaLabel?: string;
12+
linkAriaLabel?: string;
13+
className?: string;
14+
children?: React.ReactNode;
15+
onClose: () => void;
16+
}
17+
18+
export const ShareLinkDialog: React.FC<ShareLinkDialogProps> = props => {
19+
const {
20+
visible,
21+
shareUrl,
22+
title,
23+
ariaLabel,
24+
linkAriaLabel,
25+
className,
26+
children,
27+
onClose,
28+
} = props;
29+
30+
const [copySuccessful, setCopySuccessful] = React.useState(false);
31+
const inputRef = React.useRef<HTMLInputElement>(null);
32+
33+
React.useEffect(() => {
34+
if (visible) setCopySuccessful(false);
35+
}, [visible, shareUrl]);
36+
37+
const handleCopyClick = () => {
38+
if (!shareUrl) return;
39+
40+
if (pxt.BrowserUtils.isIpcRenderer()) {
41+
setCopySuccessful(!!inputRef.current && pxt.BrowserUtils.legacyCopyText(inputRef.current));
42+
return;
43+
}
44+
45+
navigator.clipboard.writeText(shareUrl);
46+
setCopySuccessful(true);
47+
};
48+
49+
const handleCopyBlur = () => {
50+
setCopySuccessful(false);
51+
};
52+
53+
if (!visible) return <></>;
54+
55+
const modalClassName = ["sharedialog", "share-link-dialog", className].filter(Boolean).join(" ");
56+
57+
return <Modal
58+
title={title || lf("Share")}
59+
className={modalClassName}
60+
parentElement={document.getElementById("root") || undefined}
61+
onClose={onClose}
62+
ariaLabel={ariaLabel || lf("Share link modal")}
63+
>
64+
<div className="project-share">
65+
<div className="project-share-info">
66+
<div className="project-share-content">
67+
<div className="project-share-data">
68+
{!!children && <div className="share-link-dialog-top">
69+
{children}
70+
</div>}
71+
72+
<div className="common-input-attached-button">
73+
<Input
74+
ariaLabel={linkAriaLabel || lf("Shareable link")}
75+
handleInputRef={(ref: HTMLInputElement) => inputRef.current = ref}
76+
initialValue={shareUrl}
77+
readOnly={true}
78+
selectOnClick={true}
79+
/>
80+
<Button
81+
className={copySuccessful ? "green" : "primary"}
82+
title={lf("Copy link")}
83+
label={copySuccessful ? lf("Copied!") : lf("Copy")}
84+
leftIcon="fas fa-link"
85+
onClick={handleCopyClick}
86+
onBlur={handleCopyBlur}
87+
/>
88+
</div>
89+
</div>
90+
</div>
91+
</div>
92+
</div>
93+
</Modal>;
94+
};

react-common/styles/share/share.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@
193193
padding: .8rem 1rem .95rem;
194194
}
195195

196+
.share-link-dialog {
197+
.share-link-dialog-top {
198+
margin-bottom: 0.75rem;
199+
}
200+
}
201+
196202
.project-share-vscode {
197203
display: flex;
198204
flex-direction: column;

theme/home.less

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,17 @@
320320
.detail {
321321
color: var(--pxt-neutral-foreground3);
322322
}
323-
.yt-button {
323+
.yt-button, button.home-share-button {
324324
display: inline-block;
325325
border-radius: 0.5rem;
326+
}
327+
.yt-button {
326328
background-color: var(--pxt-primary-background);
327329
}
330+
button.home-share-button {
331+
color: var(--pxt-neutral-foreground1);
332+
background-color: var(--pxt-target-background1);
333+
}
328334
.ui.grid.stackable .actions {
329335
padding-right: 4rem !important;
330336
position: relative;
@@ -772,32 +778,36 @@
772778

773779
.detailview {
774780
.column:first-child {
775-
height: 10.5rem;
776-
overflow: hidden;
781+
height: auto;
782+
overflow: visible;
783+
784+
.segment {
785+
padding-bottom: 1rem;
786+
}
777787
}
778788
.actions {
779-
height: 9rem;
780-
padding-right: 4rem !important;
789+
height: auto;
790+
padding-right: @carouselArrowSizeMobile !important;
781791
.card-action {
792+
display: inline-block;
793+
width: 8rem;
794+
margin: 0 0 0 0.5rem;
795+
border-width: 3px;
796+
782797
> .item, > .icon {
783798
height: 2rem;
784799
}
785800
.xicon {
786801
background-image: none!important;
787802
}
788803
.button.approve {
789-
padding: .35em 1em .5em;
804+
font-size: 0.9rem !important;
805+
padding: .35em 0.75em .5em;
790806
}
791807
.button.attached .icon:not(.xicon) {
792808
font-size: 2rem;
793809
line-height: 2rem;
794810
}
795-
&:first-child {
796-
margin-left: 0;
797-
}
798-
&:last-child {
799-
margin-right: 0;
800-
}
801811
}
802812

803813
.card-action-title {
@@ -806,11 +816,10 @@
806816
}
807817

808818
.segment {
809-
position: absolute;
810-
bottom: 0;
811-
right: 0;
812-
margin: 0 1rem 0.5rem;
813-
white-space: normal;
819+
position: static;
820+
margin: 0 0.5rem 0.5rem;
821+
text-align: right;
822+
white-space: nowrap;
814823
}
815824
}
816825
}

webapp/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3168,7 +3168,7 @@ export class ProjectView
31683168
const { name, path, loadBlocks, prj, preferredEditor } = options;
31693169
core.showLoading("changingcode", lf("loading..."));
31703170
this.loadingExample = true;
3171-
return this.loadActivityFromMarkdownAsync(path, name.toLowerCase(), preferredEditor)
3171+
return this.loadActivityFromMarkdownAsync(path, name?.toLowerCase(), preferredEditor)
31723172
.then(r => {
31733173
const { filename, md, features, autoChooseBoard: autoChooseBoardMeta } = (r || {});
31743174
const autoChooseBoard = !prj && autoChooseBoardMeta;

0 commit comments

Comments
 (0)