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

[DRAFT] wip - empty state component #33920

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from 3 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,36 @@
## API Report File for "@fluentui/react-empty-state-preview"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import { ComponentProps } from '@fluentui/react-utilities/src/index';
import { ComponentState } from '@fluentui/react-utilities/src/index';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import * as React_2 from 'react';
import type { Slot } from '@fluentui/react-utilities';

// @public (undocumented)
export const EmptyState: ForwardRefComponent<EmptyStateProps>;

// @public (undocumented)
export type EmptyStateProps = ComponentProps<EmptyStateSlots>;

// @public (undocumented)
export type EmptyStateSlots = {
root: Slot<'div'>;
title: Slot<'span'>;
};

// @public (undocumented)
export type EmptyStateState = ComponentState<EmptyStateSlots>;

// @public (undocumented)
export const renderEmptyState: (state: EmptyStateState) => JSX.Element;

// @public
export const useEmptyState: (props: EmptyStateProps, ref: React_2.Ref<HTMLElement>) => EmptyStateState;

// (No @packageDocumentation comment for this package)

```
Original file line number Diff line number Diff line change
@@ -13,6 +13,6 @@ export type EmptyStateSlots = {
title: Slot<'span'>;
};

export type EmptyStateProps = ComponentProps<EmptyStateSlots> & {};
export type EmptyStateProps = ComponentProps<EmptyStateSlots>;

export type EmptyStateState = ComponentState<EmptyStateSlots> & {};
export type EmptyStateState = ComponentState<EmptyStateSlots>;
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import type { EmptyStateProps, EmptyStateState } from './EmptyState.types';
* @param ref - reference to root HTMLElement of EmptyState
*/
export const useEmptyState = (props: EmptyStateProps, ref: React.Ref<HTMLElement>): EmptyStateState => {
const { title } = props;
const { title, ...rest } = props;

const state: EmptyStateState = {
components: {
@@ -22,7 +22,7 @@ export const useEmptyState = (props: EmptyStateProps, ref: React.Ref<HTMLElement
root: slot.always(
getIntrinsicElementProps('div', {
ref: ref as React.Ref<HTMLDivElement>,
...props,
...rest,
}),
{ elementType: 'div' },
),
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { makeStyles, makeResetStyles, mergeClasses } from '@griffel/react';
import type { SlotClassNames } from '@fluentui/react-utilities';
import { tokens } from '@fluentui/react-theme';
import type { EmptyStateSlots, EmptyStateState } from './EmptyState.types';

export const emptyStateClassNames: SlotClassNames<EmptyStateSlots> = {
root: 'fui-EmptyState',
title: 'fui-EmptyState__title',
};

/**
* Styles for the root slot
*/
const useRootStyles = makeResetStyles({
padding: '20px',
});

const useTitleStyles = makeStyles({
title: {
fontSize: tokens.fontSizeBase500,
fontWeight: tokens.fontWeightSemibold,
color: tokens.colorNeutralForeground1,
},
});

/**
* Apply styling to the ColorSlider slots based on the state
*/
export const useColorSliderStyles_unstable = (state: EmptyStateState): EmptyStateState => {
'use no memo';

const rootStyles = useRootStyles();
const titleStyles = useTitleStyles();

state.root.className = mergeClasses(emptyStateClassNames.root, rootStyles, state.root.className);

if (state.title) {
state.title.className = mergeClasses(emptyStateClassNames.title, titleStyles.title);
}

return state;
};
Original file line number Diff line number Diff line change
@@ -3,7 +3,9 @@
"version": "0.0.0",
"private": true,
"devDependencies": {
"@fluentui/react-components": "*",
"@fluentui/react-storybook-addon": "*",
"@fluentui/react-empty-state-preview": "*",
"@fluentui/react-storybook-addon-export-to-sandbox": "*",
"@fluentui/scripts-storybook": "*",
"@fluentui/eslint-plugin": "*"
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import * as React from 'react';
import { EmptyState } from '../../../library/src'; // @fluentui/react-empty-state-preview?
import { EmptyState } from '@fluentui/react-empty-state-preview';

export const EmptyStateDefault = () => <EmptyState title="No data" />;
export const EmptyStateDefault = () => {
return (
<div>
Test
{/* <EmptyState title="No data" /> */}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { EmptyState } from '@fluentui/react-empty-state-preview';

export { EmptyStateDefault } from './EmptyStateDefault.stories';

export default {
title: 'Preview Components/EmptyState',
component: EmptyState,
parameters: {
docs: {
description: 'The EmptyState component is used to indicate that there is no data to display.',
},
},
};