-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add anchor component * Fix CI * Fix anchor react component props
- Loading branch information
1 parent
e6dba47
commit 58d1a7d
Showing
11 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
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,47 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
import type { StoryFn, Meta, StoryObj } from '@storybook/html'; | ||
import { getFaIcon, setTheme } from '../utilities/storybook'; | ||
|
||
export default { | ||
title: 'Components/Anchor', | ||
argTypes: { | ||
label: { control: 'text' }, | ||
appearance: { | ||
control: 'select', | ||
options: [ | ||
'Accent', | ||
'Lightweight', | ||
'Neutral', | ||
'Outline', | ||
'Stealth', | ||
'Hypertext' | ||
] | ||
}, | ||
startIcon: { control: 'boolean' }, | ||
endIcon: { control: 'boolean' } | ||
} | ||
} as Meta; | ||
|
||
const Template: StoryFn = (args, context): string => { | ||
const { | ||
globals: { backgrounds, accent }, | ||
parameters | ||
} = context; | ||
setTheme(accent, parameters.backgrounds, backgrounds); | ||
|
||
return `<jp-anchor | ||
href="#" | ||
${args.appearance ? `appearance="${args.appearance.toLowerCase()}` : ''}"> | ||
${args.startIcon ? getFaIcon('plus', 'start') : ''}${args.label ?? 'Link'} | ||
${args.endIcon ? getFaIcon('plus', 'end') : ''} | ||
</jp-anchor>`; | ||
}; | ||
|
||
export const Default: StoryObj = { render: Template.bind({}) }; | ||
Default.args = { | ||
label: 'Link', | ||
appearance: 'Neutral', | ||
startIcon: false, | ||
endIcon: false | ||
}; |
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,12 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
import { test, expect } from '@playwright/test'; | ||
|
||
test('Default', async ({ page }) => { | ||
await page.goto('/iframe.html?id=components-anchor--default'); | ||
|
||
expect(await page.locator('jp-anchor').screenshot()).toMatchSnapshot( | ||
'anchor-default.png' | ||
); | ||
}); |
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,31 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
import { | ||
Anchor as FoundationAnchor, | ||
anchorTemplate as template | ||
} from '@microsoft/fast-foundation'; | ||
import { Anchor, anchorStyles as styles } from '@microsoft/fast-components'; | ||
|
||
/** | ||
* A function that returns a Anchor registration for configuration with a DesignSystem. | ||
* Implements {@link @microsoft/fast-foundation#anchorTemplate} | ||
* | ||
* @public | ||
* @remarks | ||
* Generates HTML Element: `<jp-anchor>` | ||
*/ | ||
export const jpAnchor = Anchor.compose({ | ||
baseName: 'anchor', | ||
baseClass: FoundationAnchor, | ||
template, | ||
styles | ||
}); | ||
|
||
/** | ||
* Base class for Anchor | ||
* @public | ||
*/ | ||
export { Anchor }; | ||
|
||
export { styles as anchorStyles }; |
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
Binary file added
BIN
+538 Bytes
...nts/tests-out/anchor/anchor.test.js-snapshots/anchor-default-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+656 Bytes
...ents/tests-out/anchor/anchor.test.js-snapshots/anchor-default-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.08 KB
...nents/tests-out/anchor/anchor.test.js-snapshots/anchor-default-webkit-linux.png
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
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,31 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
import { provideJupyterDesignSystem, jpAnchor } from '@jupyter/web-components'; | ||
import { provideReactWrapper } from '@microsoft/fast-react-wrapper'; | ||
import React from 'react'; | ||
|
||
const { wrap } = provideReactWrapper(React, provideJupyterDesignSystem()); | ||
|
||
export const Anchor: React.DetailedHTMLFactory< | ||
React.HTMLAttributes<HTMLElement> & { | ||
appearance?: | ||
| 'accent' | ||
| 'lightweight' | ||
| 'neutral' | ||
| 'outline' | ||
| 'stealth' | ||
| 'hypertext'; | ||
download?: string; | ||
href?: string; | ||
hreflang?: string; | ||
ping?: string; | ||
referrerpolicy?: string; | ||
rel?: string; | ||
target?: '_self' | '_blank' | '_parent' | '_top'; | ||
type?: string; | ||
}, | ||
HTMLElement | ||
> = wrap(jpAnchor()) as any; | ||
// @ts-expect-error unknown property | ||
Anchor.displayName = 'Jupyter.Anchor'; |
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