-
Notifications
You must be signed in to change notification settings - Fork 221
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
fix: Add Image component and CDN src support to Graphic component #3062
Open
mannycarrera4
wants to merge
9
commits into
Workday:support
Choose a base branch
from
mannycarrera4:mc-add-image-component
base: support
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1d2ca65
feat: Add Image component and update Graphics to accept a string
22ac176
fix: Update types
8ef616b
fix: Refactor docs
a9b8f02
fix: Update routes
bee0bc6
fix: Update some docs
b1084e4
fix: Update docs for image
a643134
fix: Add info to upgrade guide
afe1516
fix: Add another image example
54a2dda
Update modules/react/icon/lib/Graphic.tsx
mannycarrera4 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
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
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 |
---|---|---|
|
@@ -61,13 +61,13 @@ storiesOf('Components/Indicators/Avatar', module) | |
.add('Non-Square Image', () => ( | ||
<div className="story"> | ||
<h3>Original Rectangle Image</h3> | ||
<img alt="" src="https://placekitten.com/g/450/200" /> | ||
<img alt="" src="https://i.imgur.com/f3FZv3H.jpeg" /> | ||
<h3>Using Object Fit on a Rectangle Image</h3> | ||
<Avatar as="div" size={200} url="https://placekitten.com/g/450/200" objectFit="contain" /> | ||
<Avatar as="div" size={200} url="https://i.imgur.com/f3FZv3H.jpeg" objectFit="contain" /> | ||
<h3>Original Square Image</h3> | ||
<img alt="" src="https://placekitten.com/g/450/450" /> | ||
<img alt="" src="https://i.imgur.com/himSfZn.jpeg" height={200} width={200} /> | ||
<h3>Using a Square Image</h3> | ||
<Avatar as="div" size={200} url="https://placekitten.com/g/450/450" /> | ||
<Avatar as="div" size={200} url="https://i.imgur.com/himSfZn.jpeg" /> | ||
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. These URLs were broken, so I updated them. |
||
</div> | ||
)) | ||
.add('Lazy Loading', () => ( | ||
|
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
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,13 @@ | ||
import * as React from 'react'; | ||
|
||
import {createComponent} from '@workday/canvas-kit-react/common'; | ||
import {CSProps, handleCsProp} from '@workday/canvas-kit-styling'; | ||
|
||
export interface ImageProps extends CSProps {} | ||
|
||
export const Image = createComponent('img')({ | ||
displayName: 'Image', | ||
Component: ({...elemProps}: ImageProps, ref, Element) => { | ||
return <Element ref={ref} {...handleCsProp(elemProps)} />; | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import {SystemIconList} from './examples/IconsList/IconList'; | ||
import {AppletIconList} from './examples/IconsList/AppletIconList'; | ||
import {AccentIconList} from './examples/IconsList/AccentIconList'; | ||
import {Overview} from './examples/Overview' | ||
|
||
<Meta title="Assets/Icons List" /> | ||
|
||
## Overview | ||
|
||
<ExampleCodeBlock code={Overview} /> | ||
|
||
## Accent Icon List | ||
|
||
Accent Icons add clarity, and visual interest, they bring delight to the experience by communicating | ||
the overall tone and meaning of a page. | ||
|
||
<ExampleCodeBlock code={AccentIconList} /> | ||
|
||
## Applet Icon List | ||
|
||
Applet Icons convey entry points, categories of actions, or information sources on the Workday | ||
homepage. | ||
|
||
<ExampleCodeBlock code={AppletIconList} /> | ||
|
||
## System Icon List | ||
|
||
System Icons are symbols used to convey simple actions and functions, they are the most common icons | ||
encountered in products and help communicate metaphors at a glance. | ||
|
||
<ExampleCodeBlock code={SystemIconList} /> |
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,52 @@ | ||
|
||
import {SymbolDoc} from '@workday/canvas-kit-docs'; | ||
import {Basic} from './examples/Image/Basic'; | ||
import {FromFileSystem} from './examples/Image/FromFileSystem'; | ||
|
||
<Meta title="Images and Icons/Image" /> | ||
|
||
# Canvas Kit Image | ||
|
||
Represents an `img` element. | ||
|
||
## Installation | ||
|
||
```sh | ||
yarn add @workday/canvas-kit-react | ||
``` | ||
|
||
## Usage | ||
|
||
## Basic | ||
|
||
The `Image` component is useful when trying to render raster files or images that need additional styling like aspect ratio or object fit. It renders an `img` element and therefore you have access to all [attributes and props](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) of a native `img` tag. | ||
|
||
<ExampleCodeBlock code={Basic} /> | ||
|
||
## From File System | ||
|
||
<ExampleCodeBlock code={FromFileSystem} /> | ||
|
||
## Accessibility | ||
|
||
### Alt Text (alt): | ||
- Always provide descriptive alt text for images. This helps screen readers convey the purpose or content of the image to visually impaired users. | ||
- Use meaningful descriptions that explain the image's context in the UI. | ||
- If the image is decorative, use an empty alt attribute (alt=""), which signals assistive technologies to ignore the image. | ||
|
||
### Captioning (caption): | ||
|
||
- Include captions for images where additional explanatory text is required. | ||
- Captions should be used for graphs, charts, or any image requiring a detailed explanation. | ||
|
||
### Role and ARIA Attributes: | ||
|
||
- Avoid adding ARIA roles such as role="img" unless the component uses non-standard HTML elements. | ||
- Default `<img>` elements are already recognized as images. | ||
- Use ARIA attributes only when needed (e.g., aria-describedby for complex images with external descriptions). | ||
|
||
## API | ||
|
||
<SymbolDoc name="Image" fileName="/react/" /> | ||
|
||
|
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
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,23 @@ | ||
import React from 'react'; | ||
import {Flex} from '@workday/canvas-kit-react/layout'; | ||
import {Image} from '@workday/canvas-kit-react/icon'; | ||
|
||
import {createStyles} from '@workday/canvas-kit-styling'; | ||
|
||
const styleOverrides = { | ||
parentContainer: createStyles({ | ||
maxHeight: 300, | ||
}), | ||
}; | ||
|
||
export const Basic = () => { | ||
return ( | ||
<Flex cs={styleOverrides.parentContainer}> | ||
<Image | ||
src="https://i.imgur.com/f3FZv3H.jpeg" | ||
cs={{objectFit: 'cover', height: 200}} | ||
alt="Image of a cat pretending to be a scientist with beakers and a chalkboard behind it" | ||
/> | ||
</Flex> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
modules/react/icon/stories/examples/Image/FromFileSystem.tsx
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,21 @@ | ||
import React from 'react'; | ||
import {Flex} from '@workday/canvas-kit-react/layout'; | ||
import {Image} from '@workday/canvas-kit-react/icon'; | ||
import {createStyles} from '@workday/canvas-kit-styling'; | ||
|
||
// @ts-ignore: Cannot find module error | ||
import catImage from '../images/cat.jpg'; | ||
|
||
const styleOverrides = { | ||
parentContainer: createStyles({ | ||
maxHeight: 300, | ||
}), | ||
}; | ||
|
||
export const FromFileSystem = () => { | ||
return ( | ||
<Flex cs={styleOverrides.parentContainer}> | ||
<Image src={catImage} cs={{objectFit: 'cover', height: 200}} alt="Image of a cat mid yawn" /> | ||
</Flex> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
Wanted to add this to the upgrade guide for people moving from v10 to v11