Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Oct 8, 2024
1 parent 5dcc8ce commit bd00f64
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .changeset/grumpy-lies-bathe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Added SemanticIconProvider to provide a mechanism to swap out built-in component

```tsx
<SemanticIconProvider iconMap={iconMap}>
<StoryFn />
<App />
</SemanticIconProvider>
```
13 changes: 0 additions & 13 deletions packages/core/src/__tests__/__e2e__/link/Link.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,4 @@ describe("GIVEN a link", () => {

cy.findByTestId(/TearOutIcon/i).should("not.exist");
});

it('WHEN target is "_blank" AND IconComponent is provided, THEN should render the provided IconComponent', () => {
const CustomIcon = () => <div data-testid="CustomIcon">Custom Icon</div>;

cy.mount(
<Link href="#root" target="_blank" IconComponent={CustomIcon}>
Action
</Link>,
);

cy.findByTestId(/CustomIcon/i).should("exist");
cy.findByTestId(/TearOutIcon/i).should("not.exist");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const TestComponent = () => {
);
};

describe("SemanticIconProvider Tests", () => {
describe("SemanticIconProvider", () => {
it("should use default icons when provider is not wrapped", () => {
cy.mount(<TestComponent />);
cy.get('[data-testid="ChevronDownIcon"]').should("exist");
Expand All @@ -31,7 +31,7 @@ describe("SemanticIconProvider Tests", () => {
cy.get('[data-testid="UserSolidIcon"]').should("exist");
});

it("should override only specific icons when provider is partially wrapped", () => {
it("should support overriding only specific icons", () => {
cy.mount(
<SemanticIconProvider
iconMap={{
Expand Down Expand Up @@ -59,7 +59,7 @@ describe("SemanticIconProvider Tests", () => {
cy.get('[data-testid="UserSolidIcon"]').should("exist");
});

it("should override all icons when provider is fully wrapped", () => {
it("should support overriding all icons", () => {
cy.mount(
<SemanticIconProvider
iconMap={{
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ export const Avatar = forwardRef<HTMLDivElement, AvatarProps>(function Avatar(
const targetWindow = useWindow();
const { UserIcon } = useIcon();

const fallbackIcon = fallbackIconProp || (
<UserIcon aria-label="User Avatar" />
);
const fallbackIcon =
fallbackIconProp === undefined ? (
<UserIcon aria-label="User Avatar" />
) : (
fallbackIconProp
);

useComponentCssInjection({
testId: "salt-avatar",
Expand Down
3 changes: 3 additions & 0 deletions packages/core/stories/avatar/avatar.qa.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Avatar } from "@salt-ds/core";
import { SaltShakerIcon } from "@salt-ds/icons";
import type { Meta, StoryFn } from "@storybook/react";
import {
QAContainer,
Expand All @@ -18,6 +19,7 @@ export const AllVariantsGrid: StoryFn<QAContainerProps> = (props) => (
<Avatar size={1} name="Alex Brailescu" src={persona1 as string} />
<Avatar size={2} src="bad_url" name="Peter Piper" />
<Avatar size={3} src="bad_url" />
<Avatar size={3} fallbackIcon={<SaltShakerIcon />} />
</QAContainer>
);

Expand Down Expand Up @@ -45,6 +47,7 @@ export const NoStyleInjectionGrid: StoryFn<QAContainerNoStyleInjectionProps> = (
<Avatar size={1} name="Alex Brailescu" src={persona1 as string} />
<Avatar size={2} src="bad_url" name="Peter Piper" />
<Avatar size={3} src="bad_url" />
<Avatar size={3} fallbackIcon={<SaltShakerIcon />} />
</QAContainerNoStyleInjection>
);

Expand Down
21 changes: 21 additions & 0 deletions packages/core/stories/link/link.qa.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Link } from "@salt-ds/core";
import { UserIcon } from "@salt-ds/icons";
import type { Meta, StoryFn } from "@storybook/react";
import {
QAContainer,
Expand Down Expand Up @@ -40,6 +41,16 @@ export const AllVariantsGrid: StoryFn<QAContainerProps> = (props) => (
>
Forced visited
</Link>
<Link
href="https://www.google.com"
target="_blank"
IconComponent={UserIcon}
>
Custom icon
</Link>
<Link href="https://www.google.com" target="_blank" IconComponent={null}>
No icon
</Link>
</QAContainer>
);

Expand Down Expand Up @@ -71,6 +82,16 @@ export const NoStyleInjectionGrid: StoryFn<QAContainerNoStyleInjectionProps> = (
<strong>Strong</strong> and <small>small</small> truncation example
</Link>
</div>
<Link
href="https://www.google.com"
target="_blank"
IconComponent={UserIcon}
>
Custom icon
</Link>
<Link href="https://www.google.com" target="_blank" IconComponent={null}>
No icon
</Link>
</QAContainerNoStyleInjection>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const BreadcrumbsCollapsed = ({
return "";
});

const { OverflowIcon } = useIcon() || {};
const { OverflowIcon } = useIcon();
const key = keys ? keys.join("") : "";
const { ref, shouldFocusOnMount } =
useFocusMenuRemount<HTMLButtonElement>(key);
Expand Down
2 changes: 1 addition & 1 deletion packages/lab/src/dropdown/DropdownButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const DropdownButton = forwardRef(function DropdownButton(
window: targetWindow,
});
const { ExpandIcon } = useIcon();
const Icon = IconComponent ?? ExpandIcon;
const Icon = IconComponent === undefined ? ExpandIcon : IconComponent;
const { inFormField } = useFormFieldLegacyProps();
// FIXME: use polymorphic button
// We don't want the 'button' tag to be shown in the DOM to trigger some accessibility testing
Expand Down
2 changes: 1 addition & 1 deletion packages/lab/src/query-input/internal/ValueSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function ValueSelector(props: ValueSelectorProps) {
setHighlightedCategoryIndex,
setHighlightedIndex,
} = props;
console.log("Testtttttt");

const selectedCategoryValues = useMemo(() => {
if (!selectedCategory) {
return [];
Expand Down
2 changes: 1 addition & 1 deletion packages/lab/src/tabs-next/OverflowMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const OverflowMenu = forwardRef<HTMLDivElement, OverflowMenuProps>(
const { tabs, ...rest } = props;
const { ref, overflowCount, isOverflowing } =
useOverflowMenu<HTMLDivElement>();
const { OverflowIcon } = useIcon() || {};
const { OverflowIcon } = useIcon();
const handleRef = useForkRef(ref, forwardedRef);
const itemVisibility = useOverflowContext(
(context) => context.itemVisibility,
Expand Down

0 comments on commit bd00f64

Please sign in to comment.