File tree Expand file tree Collapse file tree 11 files changed +134
-0
lines changed
tests-out/anchor/anchor.test.js-snapshots Expand file tree Collapse file tree 11 files changed +134
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import type { StoryFn , Meta , StoryObj } from '@storybook/html' ;
4
+ import { getFaIcon , setTheme } from '../utilities/storybook' ;
5
+
6
+ export default {
7
+ title : 'Components/Anchor' ,
8
+ argTypes : {
9
+ label : { control : 'text' } ,
10
+ appearance : {
11
+ control : 'select' ,
12
+ options : [
13
+ 'Accent' ,
14
+ 'Lightweight' ,
15
+ 'Neutral' ,
16
+ 'Outline' ,
17
+ 'Stealth' ,
18
+ 'Hypertext'
19
+ ]
20
+ } ,
21
+ startIcon : { control : 'boolean' } ,
22
+ endIcon : { control : 'boolean' }
23
+ }
24
+ } as Meta ;
25
+
26
+ const Template : StoryFn = ( args , context ) : string => {
27
+ const {
28
+ globals : { backgrounds, accent } ,
29
+ parameters
30
+ } = context ;
31
+ setTheme ( accent , parameters . backgrounds , backgrounds ) ;
32
+
33
+ return `<jp-anchor
34
+ href="#"
35
+ ${ args . appearance ? `appearance="${ args . appearance . toLowerCase ( ) } ` : '' } ">
36
+ ${ args . startIcon ? getFaIcon ( 'plus' , 'start' ) : '' } ${ args . label ?? 'Link' }
37
+ ${ args . endIcon ? getFaIcon ( 'plus' , 'end' ) : '' }
38
+ </jp-anchor>` ;
39
+ } ;
40
+
41
+ export const Default : StoryObj = { render : Template . bind ( { } ) } ;
42
+ Default . args = {
43
+ label : 'Link' ,
44
+ appearance : 'Neutral' ,
45
+ startIcon : false ,
46
+ endIcon : false
47
+ } ;
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { test , expect } from '@playwright/test' ;
5
+
6
+ test ( 'Default' , async ( { page } ) => {
7
+ await page . goto ( '/iframe.html?id=components-anchor--default' ) ;
8
+
9
+ expect ( await page . locator ( 'jp-anchor' ) . screenshot ( ) ) . toMatchSnapshot (
10
+ 'anchor-default.png'
11
+ ) ;
12
+ } ) ;
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import {
5
+ Anchor as FoundationAnchor ,
6
+ anchorTemplate as template
7
+ } from '@microsoft/fast-foundation' ;
8
+ import { Anchor , anchorStyles as styles } from '@microsoft/fast-components' ;
9
+
10
+ /**
11
+ * A function that returns a Anchor registration for configuration with a DesignSystem.
12
+ * Implements {@link @microsoft/fast-foundation#anchorTemplate }
13
+ *
14
+ * @public
15
+ * @remarks
16
+ * Generates HTML Element: `<jp-anchor>`
17
+ */
18
+ export const jpAnchor = Anchor . compose ( {
19
+ baseName : 'anchor' ,
20
+ baseClass : FoundationAnchor ,
21
+ template,
22
+ styles
23
+ } ) ;
24
+
25
+ /**
26
+ * Base class for Anchor
27
+ * @public
28
+ */
29
+ export { Anchor } ;
30
+
31
+ export { styles as anchorStyles } ;
Original file line number Diff line number Diff line change 4
4
import type { Container } from '@microsoft/fast-foundation' ;
5
5
import { jpAccordion } from './accordion/index' ;
6
6
import { jpAccordionItem } from './accordion-item/index' ;
7
+ import { jpAnchor } from './anchor/index' ;
7
8
import { jpAnchoredRegion } from './anchored-region/index' ;
8
9
import { jpAvatar } from './avatar/index' ;
9
10
import { jpBadge } from './badge/index' ;
@@ -44,6 +45,7 @@ import { jpTreeView } from './tree-view/index';
44
45
/* eslint-disable @typescript-eslint/no-unused-vars */
45
46
import type { Accordion } from './accordion/index' ;
46
47
import type { AccordionItem } from './accordion-item/index' ;
48
+ import type { Anchor } from './anchor/index' ;
47
49
import type { AnchoredRegion } from './anchored-region/index' ;
48
50
import type { Avatar } from './avatar/index' ;
49
51
import type { Badge } from './badge/index' ;
@@ -83,6 +85,7 @@ import type { TreeView } from './tree-view/index';
83
85
export {
84
86
jpAccordion ,
85
87
jpAccordionItem ,
88
+ jpAnchor ,
86
89
jpAnchoredRegion ,
87
90
jpAvatar ,
88
91
jpBadge ,
@@ -131,6 +134,7 @@ export {
131
134
export const allComponents = {
132
135
jpAccordion,
133
136
jpAccordionItem,
137
+ jpAnchor,
134
138
jpAnchoredRegion,
135
139
jpAvatar,
136
140
jpBadge,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export * from './custom-elements';
11
11
// Export components and classes
12
12
export * from './accordion/index' ;
13
13
export * from './accordion-item/index' ;
14
+ export * from './anchor/index' ;
14
15
export * from './anchored-region/index' ;
15
16
export * from './avatar/index' ;
16
17
export * from './badge/index' ;
Original file line number Diff line number Diff line change 4
4
import {
5
5
Accordion ,
6
6
AccordionItem ,
7
+ Anchor ,
7
8
Avatar ,
8
9
Badge ,
9
10
Breadcrumb ,
@@ -254,6 +255,9 @@ function Artwork(props: { dataRef: React.Ref<WebDataGrid> }): JSX.Element {
254
255
< span className = "fa fa-cog" > </ span >
255
256
</ Button >
256
257
</ div >
258
+ < Anchor appearance = "outline" href = "#" >
259
+ Anchor element
260
+ </ Anchor >
257
261
< Search
258
262
value = "Dummy search text"
259
263
onChange = { onChange }
@@ -454,6 +458,9 @@ function createNode(): HTMLElement {
454
458
<jp-button appearance="neutral">Button</jp-button>
455
459
<jp-button appearance="stealth" aria-label="Confirm"><span class="fa fa-cog"></span></jp-button>
456
460
</div>
461
+ <jp-anchor appearance="outline" href="#">
462
+ Anchor element
463
+ </jp-anchor>
457
464
<jp-search value="Dummy search text">Search Label</jp-search>
458
465
<jp-text-field value="Populated text">Text Field Label</jp-text-field>
459
466
<jp-number-field value="30">Number Field Label</jp-number-field>
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { provideJupyterDesignSystem , jpAnchor } from '@jupyter/web-components' ;
5
+ import { provideReactWrapper } from '@microsoft/fast-react-wrapper' ;
6
+ import React from 'react' ;
7
+
8
+ const { wrap } = provideReactWrapper ( React , provideJupyterDesignSystem ( ) ) ;
9
+
10
+ export const Anchor : React . DetailedHTMLFactory <
11
+ React . HTMLAttributes < HTMLElement > & {
12
+ appearance ?:
13
+ | 'accent'
14
+ | 'lightweight'
15
+ | 'neutral'
16
+ | 'outline'
17
+ | 'stealth'
18
+ | 'hypertext' ;
19
+ download ?: string ;
20
+ href ?: string ;
21
+ hreflang ?: string ;
22
+ ping ?: string ;
23
+ referrerpolicy ?: string ;
24
+ rel ?: string ;
25
+ target ?: '_self' | '_blank' | '_parent' | '_top' ;
26
+ type ?: string ;
27
+ } ,
28
+ HTMLElement
29
+ > = wrap ( jpAnchor ( ) ) as any ;
30
+ // @ts -expect-error unknown property
31
+ Anchor . displayName = 'Jupyter.Anchor' ;
Original file line number Diff line number Diff line change 3
3
4
4
export * from './accordion' ;
5
5
export * from './accordion-item' ;
6
+ export * from './anchor' ;
6
7
export * from './anchored-region' ;
7
8
export * from './avatar' ;
8
9
export * from './badge' ;
You can’t perform that action at this time.
0 commit comments