-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add prototype section and page for re-use annotations features #977
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2670c7d
Establish a nav section for prototypes and a directory to hold them
lyzadanger 0bd225c
Add Pin, Info icons to support UI prototyping
lyzadanger c6c8e4e
Copy Menu components from client
lyzadanger 96168c0
Prototype UI wireframes for aspects of annotation re-use in LMS
lyzadanger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// This file was auto-generated using scripts/generate-icons.js | ||
import type { JSX } from 'preact'; | ||
|
||
export type InfoIconProps = JSX.SVGAttributes<SVGSVGElement>; | ||
|
||
/** | ||
* Icon generated from info.svg | ||
*/ | ||
export default function InfoIcon(props: InfoIconProps) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="16" | ||
height="16" | ||
viewBox="0 0 24 24" | ||
data-component="InfoIcon" | ||
{...props} | ||
> | ||
<path fill="currentColor" d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20z" /> | ||
<path | ||
fill="#fff" | ||
d="M11 12a1 1 0 0 1 0-2h2a1 1 0 0 1 .96 1.27L12.33 17H13a1 1 0 0 1 0 2h-2a1 1 0 0 1-.96-1.27L11.67 12H11zm2-4a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z" | ||
/> | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// This file was auto-generated using scripts/generate-icons.js | ||
import type { JSX } from 'preact'; | ||
|
||
export type PinIconProps = JSX.SVGAttributes<SVGSVGElement>; | ||
|
||
/** | ||
* Icon generated from pin.svg | ||
*/ | ||
export default function PinIcon(props: PinIconProps) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="16" | ||
height="16" | ||
class="icon-pin" | ||
viewBox="0 0 24 24" | ||
data-component="PinIcon" | ||
{...props} | ||
> | ||
<path | ||
fill="currentColor" | ||
d="m2.24 20.35 6.5-7.5a1 1 0 0 1 1.47-.06l1 1a1 1 0 0 1-.06 1.47l-7.5 6.5c-.93.8-2.22-.48-1.4-1.41z" | ||
class="secondary" | ||
/> | ||
<path | ||
fill="currentColor" | ||
d="M15 15.41V18a1 1 0 0 1-.3.7l-1 1a1 1 0 0 1-1.4 0l-8-8a1 1 0 0 1 0-1.4l1-1A1 1 0 0 1 6 9h2.59L13 4.59V3a1 1 0 0 1 1.7-.7l7 7A1 1 0 0 1 21 11h-1.59L15 15.41z" | ||
class="primary" | ||
/> | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
139 changes: 139 additions & 0 deletions
139
src/pattern-library/components/patterns/prototype/FakeAnnotationPublishControl.tsx
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a simplified, shortened and adapted variant of the client's |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import classnames from 'classnames'; | ||
|
||
import { | ||
Button, | ||
CancelIcon, | ||
GlobeIcon, | ||
GroupsIcon, | ||
InfoIcon, | ||
LockIcon, | ||
MenuExpandIcon, | ||
} from '../../../..'; | ||
import Menu from './Menu'; | ||
import MenuItem from './MenuItem'; | ||
|
||
export type AnnotationPublishControlProps = { | ||
/** The group this annotation or draft would publish to */ | ||
group: string; | ||
|
||
/** | ||
* Should the save button be disabled? Hint: it will be if the annotation has | ||
* no content | ||
*/ | ||
isDisabled?: boolean; | ||
|
||
/** Annotation or draft is "Only Me" */ | ||
isPrivate?: boolean; | ||
|
||
noSharing?: boolean; | ||
|
||
noSharingMessage?: string; | ||
|
||
/** Callback for cancel button click */ | ||
onCancel?: () => void; | ||
|
||
/** Callback for save button click */ | ||
onSave?: () => void; | ||
}; | ||
|
||
/** | ||
* Render a compound control button for publishing (saving) an annotation: | ||
* - Save the annotation — left side of button | ||
* - Choose sharing/privacy option - drop-down menu on right side of button | ||
* | ||
* @param {AnnotationPublishControlProps} props | ||
*/ | ||
function AnnotationPublishControl({ | ||
group, | ||
isDisabled = false, | ||
isPrivate = false, | ||
noSharing = false, | ||
noSharingMessage = "Why can't I share this annotation?", | ||
onCancel = () => {}, | ||
onSave = () => {}, | ||
}: AnnotationPublishControlProps) { | ||
const menuLabel = ( | ||
<div className="w-9 h-9 flex items-center justify-center text-color-text-inverted"> | ||
<MenuExpandIcon className="w-4 h-4" /> | ||
</div> | ||
); | ||
|
||
return ( | ||
<div className="flex flex-row gap-x-3"> | ||
<div className="flex relative"> | ||
<Button | ||
classes={classnames( | ||
// Turn off right-side border radius to align with menu-open button | ||
'rounded-r-none' | ||
)} | ||
data-testid="publish-control-button" | ||
onClick={onSave} | ||
disabled={isDisabled} | ||
size="lg" | ||
variant="primary" | ||
> | ||
Post to {isPrivate ? 'Only Me' : group} | ||
</Button> | ||
{/* This wrapper div is necessary because of peculiarities with | ||
Safari: see https://github.com/hypothesis/client/issues/2302 */} | ||
<div | ||
className={classnames( | ||
// Round the right side of this menu-open button only | ||
'flex flex-row rounded-r-sm bg-grey-7 hover:bg-grey-8' | ||
)} | ||
> | ||
<Menu | ||
arrowClass={classnames( | ||
// Position up-pointing menu caret aligned beneath the | ||
// down-pointing menu-open button icon | ||
'right-[10px]' | ||
)} | ||
containerPositioned={false} | ||
contentClass={classnames( | ||
// Ensure the menu is wide enough to "reach" the right-aligned | ||
// up-pointing menu arrow | ||
'min-w-full' | ||
)} | ||
defaultOpen | ||
label={menuLabel} | ||
menuIndicator={false} | ||
title="Change annotation sharing setting" | ||
align="left" | ||
> | ||
<MenuItem | ||
icon={GroupsIcon} | ||
label={`${group} only`} | ||
isSelected={!isPrivate} | ||
/> | ||
<MenuItem | ||
icon={GlobeIcon} | ||
label="All course participants" | ||
isDisabled={noSharing} | ||
/> | ||
{noSharing && ( | ||
<div className="bg-grey-0 text-color-text-light"> | ||
<div className="flex gap-x-1 items-center pb-1 pl-[11px]"> | ||
<div> | ||
<InfoIcon className="w-[12px] h-[12px]" /> | ||
</div> | ||
<div className="text-xs px-2 italic text-color-text-light min-w-min whitespace-nowrap"> | ||
{noSharingMessage} | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
<MenuItem icon={LockIcon} label="Only Me" isSelected={isPrivate} /> | ||
</Menu> | ||
</div> | ||
</div> | ||
<div> | ||
<Button data-testid="cancel-button" onClick={onCancel} size="lg"> | ||
<CancelIcon /> | ||
Cancel | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default AnnotationPublishControl; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will ensure that the
prototype
directory sticks around if we remove any pages inside of it.