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

feat: view #121

Merged
merged 17 commits into from
Apr 18, 2023
Merged

feat: view #121

merged 17 commits into from
Apr 18, 2023

Conversation

JackyxCS
Copy link
Contributor

@JackyxCS JackyxCS commented Apr 11, 2023

resolves #122

image

@github-actions
Copy link

github-actions bot commented Apr 11, 2023

size-limit report 📦

Path Size
dist/components.cjs.production.min.js 151.83 KB (+0.21% 🔺)
dist/components.esm.js 101.44 KB (+0.34% 🔺)

@JackyxCS JackyxCS marked this pull request as ready for review April 11, 2023 18:39
src/view/View.tsx Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
src/view/View.tsx Show resolved Hide resolved
src/view/View.tsx Outdated Show resolved Hide resolved
src/view/View.tsx Show resolved Hide resolved
src/view/styles.ts Outdated Show resolved Hide resolved
src/view/styles.ts Outdated Show resolved Hide resolved
Comment on lines 23 to 25
borderRadius?: 'small' | 'medium';
borderColor?: 'light' | 'dark';
backgroundColor?: 'light' | 'dark';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JackyxCS we need to move these to explicit types that can be re-used like DimensionValue e.g. we need BorderRadius etc.

: 'transparent'};
border-radius: ${borderRadius != null
? `var(--ac-global-rounding-${borderRadius})`
: 0};
width: ${width != null ? dimensionValue(width) : 0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JackyxCS let's look into how spectrum gets a nice default width. I think that's probably the behavior we want

@JackyxCS
Copy link
Contributor Author

@mikeldking took another pass and added types and add'l gallery views, lmk if anything else to consider! Seems like a default of 'auto' for width and height matches spectrum's behavior


export type BorderColorValue = BorderColorAlias;

export type BackgroundColorValue = BorderColorAlias;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't assign types like this where the semantics doesn't make sense. Naming things properly is very important - code is read 90% more than it is written. I would argue that you could just have assigned them to separate sets.

Suggested change
export type BackgroundColorValue = BorderColorAlias;
type BorderColorValue = "light" | "dark";
type BackgroundColorValue = "light" | dark";

This is more true to form - they legitimately are separate values

If the concept of light and dark is meant to be consistent across, then something along the lines of

type LightOrDark = "light" | "dark"

Could be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, missed the fact that light and dark are truly separate colors for border/background and will keep the naming in mind for the future!

height: ${height != null ? dimensionValue(height) : 'auto'};
`}
className="ac-view"
aria-labelledby={viewId}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems incorrect - what's the rationale here?

Copy link
Contributor Author

@JackyxCS JackyxCS Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should just be id={id} misinterpreted the use of aria-labelledby since there's not another element to relate it to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess we wouldn't need an aria-label here since it's not an interactive element?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-labelledby is typically for form fields https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby

It's not needed if you don't use semantic markup. E.g.

<label><input /></label>

doesn't need this vs

<label id="foo">foo</label>
<input aria-labelledby="foo" />

@JackyxCS JackyxCS merged commit 1028284 into main Apr 18, 2023
@JackyxCS JackyxCS deleted the view-component branch April 18, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UI Components] View
2 participants