Skip to content
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": "prerelease",
"comment": "export static classes for components",
"packageName": "@fluentui/react-card",
"email": "olfedias@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "export static classes for components",
"packageName": "@fluentui/react-image",
"email": "olfedias@microsoft.com",
"dependentChangeType": "patch"
}
12 changes: 12 additions & 0 deletions packages/react-card/etc/react-card.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ import * as React_2 from 'react';
// @public
export const Card: ForwardRefComponent<CardProps>;

// @public (undocumented)
export const cardClassName = "fui-Card";

// @public (undocumented)
export type CardCommons = {};

// @public
export const CardFooter: ForwardRefComponent<CardFooterProps>;

// @public (undocumented)
export const cardFooterClassName = "fui-CardFooter";

// @public
export type CardFooterProps = ComponentProps<CardFooterSlots>;

Expand All @@ -37,6 +43,9 @@ export type CardFooterState = ComponentState<CardFooterSlots>;
// @public
export const CardHeader: ForwardRefComponent<CardHeaderProps>;

// @public (undocumented)
export const cardHeaderClassName = "fui-CardHeader";

// @public
export type CardHeaderProps = ComponentProps<CardHeaderSlots>;

Expand All @@ -59,6 +68,9 @@ export type CardHeaderState = ComponentState<CardHeaderSlots>;
// @public
export const CardPreview: ForwardRefComponent<CardPreviewProps>;

// @public (undocumented)
export const cardPreviewClassName = "fui-CardPreview";

// @public
export type CardPreviewProps = ComponentProps<CardPreviewSlots>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Card renders a default state 1`] = `
<div>
<div
class=""
class="fui-Card"
data-tabster="{\\"groupper\\":{\\"tabbability\\":2}}"
role="group"
>
Expand Down
6 changes: 5 additions & 1 deletion packages/react-card/src/components/Card/useCardStyles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import { cardPreviewClassName } from '../CardPreview/index';
import type { CardState } from './Card.types';

export const cardClassName = 'fui-Card';

/**
* Styles for the root slot
*/
Expand All @@ -21,7 +24,7 @@ const useStyles = makeStyles({
gap: '12px',
borderRadius: theme.borderRadiusMedium,

'> .fluentui-react-card-preview': {
[`> .${cardPreviewClassName}`]: {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I updated selector to use the constant, classnames in CardPreview were also updated.

marginLeft: '-12px',
marginRight: '-12px',
'&:first-child': {
Expand All @@ -47,6 +50,7 @@ const useStyles = makeStyles({
export const useCardStyles = (state: CardState): CardState => {
const styles = useStyles();
state.root.className = mergeClasses(
cardClassName,
styles.root,
(state.root.onClick ||
state.root.onMouseUp ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`CardFooter renders a default state 1`] = `
<div>
<div
class=""
class="fui-CardFooter"
>
Default CardFooter
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import type { CardFooterState } from './CardFooter.types';

export const cardFooterClassName = 'fui-CardFooter';

/**
* Styles for the root slot
*/
Expand All @@ -20,7 +22,7 @@ const useStyles = makeStyles({
*/
export const useCardFooterStyles = (state: CardFooterState): CardFooterState => {
const styles = useStyles();
state.root.className = mergeClasses(styles.root, state.root.className);
state.root.className = mergeClasses(cardFooterClassName, styles.root, state.root.className);

if (state.action) {
state.action.className = mergeClasses(styles.action, state.action.className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`CardHeader renders a default state 1`] = `
<div>
<div
class=""
class="fui-CardHeader"
>
<div
class=""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import type { CardHeaderState } from './CardHeader.types';

export const cardHeaderClassName = 'fui-CardHeader';

/**
* Styles for the root slot
*/
Expand Down Expand Up @@ -46,7 +48,7 @@ const useStyles = makeStyles({
*/
export const useCardHeaderStyles = (state: CardHeaderState): CardHeaderState => {
const styles = useStyles();
state.root.className = mergeClasses(styles.root, state.root.className);
state.root.className = mergeClasses(cardHeaderClassName, styles.root, state.root.className);

if (state.image) {
state.image.className = mergeClasses(styles.image, state.image.className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`CardPreview renders a default state 1`] = `
<div>
<div
class="fluentui-react-card-preview"
class="fui-CardPreview"
>
Default CardPreview
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import type { CardPreviewState } from './CardPreview.types';

export const cardPreviewClassName = 'fui-CardPreview';

/**
* Styles for the root slot
*/
Expand Down Expand Up @@ -30,7 +32,7 @@ const useStyles = makeStyles({
*/
export const useCardPreviewStyles = (state: CardPreviewState): CardPreviewState => {
const styles = useStyles();
state.root.className = mergeClasses('fluentui-react-card-preview', styles.root, state.root.className);
state.root.className = mergeClasses(cardPreviewClassName, styles.root, state.root.className);

if (state.logo) {
state.logo.className = mergeClasses(styles.logo, state.logo.className);
Expand Down
3 changes: 3 additions & 0 deletions packages/react-image/etc/react-image.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import * as React_2 from 'react';
const Image_2: ForwardRefComponent<ImageProps>;
export { Image_2 as Image }

// @public (undocumented)
export const imageClassName = "fui-Image";

// @public (undocumented)
export type ImageCommons = {
bordered?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Image renders a default state 1`] = `
<div>
<img
alt="Non-existent image"
class=""
class="fui-Image"
src="image.png"
/>
</div>
Expand Down
3 changes: 3 additions & 0 deletions packages/react-image/src/components/Image/useImageStyles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { mergeClasses, makeStyles } from '@fluentui/react-make-styles';
import type { ImageState } from './Image.types';

export const imageClassName = 'fui-Image';

const useStyles = makeStyles({
root: theme => ({
borderColor: theme.colorNeutralStroke1,
Expand Down Expand Up @@ -54,6 +56,7 @@ const useStyles = makeStyles({
export const useImageStyles = (state: ImageState) => {
const styles = useStyles();
state.root.className = mergeClasses(
imageClassName,
styles.root,
state.bordered && styles.rootBordered,
state.shape === 'circular' && styles.rootCircular,
Expand Down
3 changes: 3 additions & 0 deletions packages/react-radio/etc/react-radio.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import * as React_2 from 'react';
// @public
export const Radio: ForwardRefComponent<RadioProps>;

// @public (undocumented)
export const radioClassName = "fui-Radio";

// @public (undocumented)
export type RadioCommons = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Radio renders a default state 1`] = `
<div>
<span
class=""
class="fui-Radio"
>
Default Radio
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import { RadioState } from './Radio.types';

export const radioClassName = 'fui-Radio';

/**
* Styles for the root slot
*/
Expand All @@ -17,7 +19,7 @@ const useStyles = makeStyles({
*/
export const useRadioStyles = (state: RadioState): RadioState => {
const styles = useStyles();
state.root.className = mergeClasses(styles.root, state.root.className);
state.root.className = mergeClasses(radioClassName, styles.root, state.root.className);

// TODO Add class names to slots, for example:
// state.mySlot.className = mergeClasses(styles.mySlot, state.mySlot.className);
Expand Down