Skip to content

Fix: Implement Custom Style Hook for Card component #33912

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "fix: implemented custom style hook for Card, CardFooter, CardHeader, CardPreview",
"packageName": "@fluentui/react-card",
"email": "terynkum@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@fluentui/keyboard-keys": "^9.0.8",
"@fluentui/react-jsx-runtime": "^9.0.50",
"@fluentui/react-shared-contexts": "^9.21.2",
"@fluentui/react-tabster": "^9.24.0",
"@fluentui/react-text": "^9.4.32",
"@fluentui/react-theme": "^9.1.24",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useCardStyles_unstable } from './useCardStyles.styles';
import type { CardProps } from './Card.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { useCardContextValue } from './useCardContextValue';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';

/**
* A card provides scaffolding for hosting actions and content for a single topic.
Expand All @@ -14,6 +15,9 @@ export const Card: ForwardRefComponent<CardProps> = React.forwardRef<HTMLDivElem
const cardContextValue = useCardContextValue(state);

useCardStyles_unstable(state);

useCustomStyleHook_unstable('useCardStyles_unstable')(state);

return renderCard_unstable(state, cardContextValue);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { renderCardFooter_unstable } from './renderCardFooter';
import { useCardFooterStyles_unstable } from './useCardFooterStyles.styles';
import type { CardFooterProps } from './CardFooter.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';

/**
* Component to render Button actions in a Card component.
Expand All @@ -12,6 +13,9 @@ export const CardFooter: ForwardRefComponent<CardFooterProps> = React.forwardRef
const state = useCardFooter_unstable(props, ref);

useCardFooterStyles_unstable(state);

useCustomStyleHook_unstable('useCardFooterStyles_unstable')(state);

return renderCardFooter_unstable(state);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { renderCardHeader_unstable } from './renderCardHeader';
import { useCardHeaderStyles_unstable } from './useCardHeaderStyles.styles';
import type { CardHeaderProps } from './CardHeader.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';

/**
* Component to render an image, text and an action in a Card component.
Expand All @@ -12,6 +13,9 @@ export const CardHeader: ForwardRefComponent<CardHeaderProps> = React.forwardRef
const state = useCardHeader_unstable(props, ref);

useCardHeaderStyles_unstable(state);

useCustomStyleHook_unstable('useCardHeaderStyles_unstable')(state);

return renderCardHeader_unstable(state);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { renderCardPreview_unstable } from './renderCardPreview';
import { useCardPreviewStyles_unstable } from './useCardPreviewStyles.styles';
import type { CardPreviewProps } from './CardPreview.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';

/**
* Component to render image previews of documents or articles in a Card component.
Expand All @@ -12,6 +13,9 @@ export const CardPreview: ForwardRefComponent<CardPreviewProps> = React.forwardR
const state = useCardPreview_unstable(props, ref);

useCardPreviewStyles_unstable(state);

useCustomStyleHook_unstable('useCardPreviewStyles_unstable')(state);

return renderCardPreview_unstable(state);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import * as React from 'react';

import { makeStyles, Body1, Caption1, Button } from '@fluentui/react-components';
import {
makeStyles,
Body1,
Caption1,
Button,
Card,
CardFooter,
CardHeader,
CardPreview,
} from '@fluentui/react-components';
import { ArrowReplyRegular, ShareRegular } from '@fluentui/react-icons';
import { Card, CardFooter, CardHeader, CardPreview } from '@fluentui/react-components';

const resolveAsset = (asset: string) => {
const ASSET_URL =
Expand Down