Skip to content
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

Adds Fluent Image web component #26622

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7e1fa62
WIP. Adds component code template.
halerankin Jan 31, 2023
7f2cffe
WIP. Adds fluent image component code template.
halerankin Jan 31, 2023
85a03d2
Generates api report.
halerankin Jan 31, 2023
6fd0fc7
Adds component doc with spec details.
halerankin Jan 31, 2023
a90f7a2
Refines spec and component API.
halerankin Feb 1, 2023
83a3830
Updated spec and component template, styles and story.
halerankin Feb 2, 2023
97a42c0
Updates component types, template, styles and story. Adds story examp…
halerankin Feb 3, 2023
80713d7
Revises component, template, story and styles to make use of slot. Mo…
halerankin Feb 3, 2023
85e84c2
Revises border-radius prop usage. Updates docs. Adds separate block l…
halerankin Feb 3, 2023
66305e6
Cleans up implementation of alt and role attributes to prevent a11y c…
halerankin Feb 3, 2023
dad1657
Renames CSS slector for border-radius attribute.
halerankin Feb 10, 2023
81f0121
Removed block, margin, alt, role and src from component, story and st…
halerankin Feb 13, 2023
dde80ec
Added block again to reflect the React API. Revised border radius to …
halerankin Feb 13, 2023
09b44a7
update fast element and foundation versions for wc-3 branch (#26844)
chrisdholt Feb 15, 2023
e1be118
applying package updates
Feb 15, 2023
ae03f3e
chore(web-components): introduce ts-solution configs and monorepo set…
Hotell Feb 15, 2023
226b7af
fix(web-components): dont ship non production assets to npm registry …
Hotell Feb 15, 2023
b79b33d
Manual bump of web components version (#26878)
JustSlone Feb 16, 2023
e6e9ee0
Renames BorderRadius const. Re-orders exports.
halerankin Feb 17, 2023
5a48e77
applying package updates
Feb 17, 2023
231db47
WIP. Adds component code template.
halerankin Jan 31, 2023
2d3ed88
WIP. Adds fluent image component code template.
halerankin Jan 31, 2023
a80e862
Generates api report.
halerankin Jan 31, 2023
0b61614
Adds component doc with spec details.
halerankin Jan 31, 2023
26f0447
Refines spec and component API.
halerankin Feb 1, 2023
2dd6974
Updated spec and component template, styles and story.
halerankin Feb 2, 2023
6df9a6e
Updates component types, template, styles and story. Adds story examp…
halerankin Feb 3, 2023
a2d2a55
Revises component, template, story and styles to make use of slot. Mo…
halerankin Feb 3, 2023
4fd6207
Revises border-radius prop usage. Updates docs. Adds separate block l…
halerankin Feb 3, 2023
35749c4
Cleans up implementation of alt and role attributes to prevent a11y c…
halerankin Feb 3, 2023
4817479
Renames CSS slector for border-radius attribute.
halerankin Feb 10, 2023
a7a45fd
Removed block, margin, alt, role and src from component, story and st…
halerankin Feb 13, 2023
3efc68f
Added block again to reflect the React API. Revised border radius to …
halerankin Feb 13, 2023
50e803d
Renames BorderRadius const. Re-orders exports.
halerankin Feb 17, 2023
390fbde
Merge branch 'dev/harankin/fluentImageWebComponent' of https://github…
halerankin Feb 17, 2023
b56e53e
Generated api report. Corrected function path.
halerankin Feb 17, 2023
6fda249
Adds change file
halerankin Feb 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,20 @@ export const lineHeightHero800: CSSDesignToken<string>;
// @public (undocumented)
export const lineHeightHero900: CSSDesignToken<string>;

// @public
class Image_2 extends FASTElement {
}
export { Image_2 as Image }

// @public
export const ImageDefinition: FASTElementDefinition<typeof Image_2>;

// @public
export const ImageStyles: ElementStyles;

// @public
export const ImageTemplate: ElementViewTemplate<Image_2>;

// @public
export class ProgressBar extends FASTProgress {
shape: ProgressBarShape;
Expand Down
4 changes: 4 additions & 0 deletions packages/web-components/src/image/define.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { definition } from './image.definition.js';

definition.define(FluentDesignSystem.registry);
17 changes: 17 additions & 0 deletions packages/web-components/src/image/image.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { Image } from './image.js';
import { template } from './image.template.js';
import { styles } from './image.styles.js';

/**
* The Fluent Image Element
*
* @public
* @remarks
* HTML Element: \<fluent-image\>
*/
export const definition = Image.compose({
name: `${FluentDesignSystem.prefix}-image`,
template,
styles,
});
83 changes: 83 additions & 0 deletions packages/web-components/src/image/image.docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Fluent Image Component

## Component Description

Images, like photos and illustrations, help reinforce a message and express your product or app’s style.

## Design Spec

[Image Spec in Figma](https://www.figma.com/file/05wt6TAsEmgsCVZfPrpcWx/Image?t=uEvu1KnTefdTZHJC-6)

## Engineering Spec

### Inputs

**content**

- @attr public alt: string | Requires description if image role is not set to presentation.
- @attr public role: string
- @attr public src: string

**booleans**

- @attr public block: boolean | false
- @attr public border: boolean | false
- @attr public margin: boolean | false
- @attr public shadow: boolean | false

**options**

- @attr public border-radius: 'small' | 'medium' | 'large' | 'x-large'
- @attr public fit: 'none' | 'center' | 'contain' | 'cover' | 'default'
- @attr public shape: 'square' | 'rounded' | 'circular'

### Slots

1 slot for developer to add <img/> element.

## Accessibility

The image element requires an alt tag when not used in role: presentation.

## Preparation

This will extend the FASTElement.

This appears to be indentical to the [Fluent UI React V9 Image component](https://master--628d031b55e942004ac95df1.chromatic.com/?path=/docs/components-image--default) in terms of props except for the following:

margin: optional 16px margin

However, when looking at the [component code](https://github.com/microsoft/fluentui/blob/master/packages/react/src/components/Image), they differ significantly.

Open GitHub issues related to Image component

- [Feature request](https://github.com/microsoft/fluentui/issues/26452)
- [Bug](https://github.com/microsoft/fluentui/issues/26399)

## Implementation

@miro - are these necessary?

- [?] Initial conformance and unit tests (validate basic functionality)

- [?] README.md covering basic usage

- [x] Uses design tokens for styling
- [?] Renders correctly in High Contrast mode

## Validation

@miro - are these necessary?

- [ ] [Add tests](https://github.com/microsoft/fluentui/wiki/Component-Implementation-Guide#tests)
- [ ] Unit and conformance tests
- [ ] Bundle size fixtures
- [ ] Performance test scenario
- [ ] Accessibility behavior tests
- [ ] Create an issue and run [manual accessibility tests](https://github.com/microsoft/fluentui/wiki/Manual-Accessibility-Review-Checklist): [link to issue]
- [ ] [Validate with partners](https://github.com/microsoft/fluentui/wiki/Component-Implementation-Guide#validation)
- [ ] [Finalize documentation](https://github.com/microsoft/fluentui/wiki/Component-Implementation-Guide#finalize-documentation)
- [ ] Review and add any missing storybook stories
- [ ] Finalize migration guide
- [ ] In package.json: Remove the alpha/beta tag from the version number in package.json
- [ ] In package.json: Change beachball's `disallowedChangeTypes` to `"major", "prerelease"`
46 changes: 46 additions & 0 deletions packages/web-components/src/image/image.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ValuesOf } from '@microsoft/fast-foundation';

/**
* Border radius
* @public
*/
export const BorderRadius = {
halerankin marked this conversation as resolved.
Show resolved Hide resolved
small: 'small',
medium: 'medium',
large: 'large',
xlarge: 'x-large',
} as const;
/**
* Types for border radius
* @public
*/
export type BorderRadius = ValuesOf<typeof BorderRadius>;

/**
* Image fit
* @public
*/
export const ImageFit = {
chrisdholt marked this conversation as resolved.
Show resolved Hide resolved
none: 'none',
center: 'center',
contain: 'contain',
cover: 'cover',
default: 'default',
halerankin marked this conversation as resolved.
Show resolved Hide resolved
} as const;
/**
* Types for image fit
* @public
*/
export type ImageFit = ValuesOf<typeof ImageFit>;

/**
* Image shape
* @public
*/
export const ImageShape = {
circular: 'circular',
rounded: 'rounded',
square: 'square',
} as const;

export type ImageShape = ValuesOf<typeof ImageShape>;
Loading