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

Publish Initial Tooltip Package #3237

Merged
merged 47 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
21c3904
new tooltip folders
gulnazsayed Apr 10, 2023
efed626
updated package.json
gulnazsayed Apr 10, 2023
da06a91
added props
gulnazsayed May 22, 2023
d159c7c
added native tooltip view
gulnazsayed May 22, 2023
950bc43
js changes
gulnazsayed Jun 7, 2023
110287b
added test page
gulnazsayed Jun 12, 2023
2e2d345
updated platform status
gulnazsayed Jun 12, 2023
74ab272
adding tooltip test page
gulnazsayed Jul 10, 2023
85e28f2
added more tooltip enabled components in test file
gulnazsayed Sep 26, 2023
7b62937
code cleanup and test positioning prop
gulnazsayed Sep 29, 2023
446900a
fixed props/bundling issue and updated dependencies
gulnazsayed Nov 13, 2023
2b6391d
test description
gulnazsayed Nov 13, 2023
79e3919
updated prop comments and removed empty tokens
gulnazsayed Nov 13, 2023
2c23acd
remove comments
gulnazsayed Nov 16, 2023
cbc4b20
changed jest to win32
gulnazsayed Nov 16, 2023
0e5b2ec
Merge branch 'main' into tooltip/new
gulnazsayed Nov 16, 2023
9aa9494
updated dependencies
gulnazsayed Nov 20, 2023
4456111
Merge branch 'tooltip/new' of https://github.com/gulnazsayed/fluentui…
gulnazsayed Nov 20, 2023
da2654b
set importHelper
gulnazsayed Nov 20, 2023
3883d29
Merge branch 'master' into tooltip/new
gulnazsayed Nov 20, 2023
0bf4fd7
update dependency versions
gulnazsayed Nov 21, 2023
df3051d
tentatively updating yarn.lock
gulnazsayed Nov 21, 2023
402aacf
Change files
gulnazsayed Nov 21, 2023
9c7eddb
fixing dependencies
gulnazsayed Nov 21, 2023
a715809
capabilities
gulnazsayed Nov 21, 2023
0cb7dbc
update yarn.lock
gulnazsayed Nov 21, 2023
dffed1c
update dependencies
gulnazsayed Nov 21, 2023
5558d22
update yarn.lock
gulnazsayed Nov 21, 2023
9a3309b
fixed import orders
gulnazsayed Nov 21, 2023
2f1a253
update target type
gulnazsayed Nov 21, 2023
bfeb69f
add capabilities
gulnazsayed Nov 22, 2023
1a408a1
add dependency and remove unused capabilities
gulnazsayed Nov 22, 2023
c4d8c26
update yarn.lock
gulnazsayed Nov 22, 2023
e8de9c8
update snapshots
gulnazsayed Nov 22, 2023
aae1d5c
add style prop to Tooltip to avoid layout issues
gulnazsayed Nov 27, 2023
f061424
add separate position test
gulnazsayed Nov 28, 2023
224b86c
testing comment
gulnazsayed Nov 28, 2023
789f14f
fixing comments
gulnazsayed Nov 28, 2023
27f4f98
fixing more comments
gulnazsayed Nov 28, 2023
8a15b2a
removed useTooltip and changed to stagedComponent
gulnazsayed Nov 28, 2023
9fe4489
fixing more comments
gulnazsayed Nov 28, 2023
296118c
fixed pr comments
gulnazsayed Nov 28, 2023
42aa392
updated button import
gulnazsayed Nov 30, 2023
a0af086
fixed lint errors
gulnazsayed Nov 30, 2023
5b61c04
yarn.lock
gulnazsayed Nov 30, 2023
d830561
Merge branch 'master' into tooltip/new
gulnazsayed Nov 30, 2023
8baef75
yarn.lock
gulnazsayed Nov 30, 2023
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
2 changes: 2 additions & 0 deletions apps/E2E/src/Tooltip/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const HOMEPAGE_TOOLTIP_BUTTON = 'Homepage_Tooltip_Button';
export const TOOLTIP_TESTPAGE = 'Tooltip_TestPage';
1 change: 1 addition & 0 deletions apps/E2E/src/index.consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ export * from './TabsV1/consts';
export * from './TextLegacy/consts';
export * from './TextV1/consts';
export * from './Theme/consts';
export * from './Tooltip/consts';
export * from './VibrancyView/consts';
1 change: 1 addition & 0 deletions apps/fluent-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@fluentui-react-native/theme-types": ">=0.33.0 <1.0.0",
"@fluentui-react-native/themed-stylesheet": "^1.6.0",
"@fluentui-react-native/theming-utils": ">=0.25.0 <1.0.0",
"@fluentui-react-native/tooltip": "0.1.0",
"@fluentui-react-native/vibrancy-view": ">=0.1.0 <1.0.0",
"@fluentui-react-native/win32-theme": ">=0.28.0 <1.0.0",
"@fluentui/react-native": ">=0.39.0 <1.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';
import { View } from 'react-native';

import { ButtonV1 } from '@fluentui-react-native/button';
import { Tooltip } from '@fluentui-react-native/tooltip';

export const TooltipDefault: React.FunctionComponent = () => {
return (
<View>
<Tooltip content="Tooltip should show under mouse cursor">
<ButtonV1>Test</ButtonV1>
</Tooltip>
gulnazsayed marked this conversation as resolved.
Show resolved Hide resolved
</View>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import { View } from 'react-native';

import { ButtonV1 } from '@fluentui-react-native/button';
import { Tooltip } from '@fluentui-react-native/tooltip';

export const TooltipPosition: React.FunctionComponent = () => {
const topCenterRef = React.useRef<View>(null);

return (
<View>
<Tooltip content="Test" positioning="topCenter">
<ButtonV1>No Target + TopCenter</ButtonV1>
</Tooltip>
<Tooltip content="Test" positioning="topCenter" target={topCenterRef}>
<ButtonV1 componentRef={topCenterRef}>Target + TopCenter</ButtonV1>
</Tooltip>
{/* Adding more tests as follow-up*/}
</View>
);
};
35 changes: 35 additions & 0 deletions apps/fluent-tester/src/TestComponents/Tooltip/TooltipTest.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from 'react';

import { TOOLTIP_TESTPAGE } from '../../../../E2E/src/Tooltip/consts';
import { TooltipDefault } from './TooltipDefault';
import { TooltipPosition } from './TooltipPosition';
import { Test } from '../Test';
import type { TestSection, PlatformStatus } from '../Test';

const tooltipSections: TestSection[] = [
{
name: 'Default',
testID: TOOLTIP_TESTPAGE,
component: TooltipDefault,
},
{
name: 'Target + Positioning',
testID: TOOLTIP_TESTPAGE,
gulnazsayed marked this conversation as resolved.
Show resolved Hide resolved
component: TooltipPosition,
},
];

export const TooltipTest: React.FunctionComponent = () => {
const status: PlatformStatus = {
win32Status: 'Experimental',
uwpStatus: 'Backlog',
iosStatus: 'Backlog',
macosStatus: 'Backlog',
androidStatus: 'Backlog',
};

const description =
'A Tooltip component displays additional information about another component. Tooltip is not expected to handle interactive content.';

return <Test name="Tooltip Test" description={description} sections={tooltipSections} status={status} />;
};
1 change: 1 addition & 0 deletions apps/fluent-tester/src/TestComponents/Tooltip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TooltipTest';
7 changes: 7 additions & 0 deletions apps/fluent-tester/src/testPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { TabsV1Test } from './TestComponents/TabsV1';
import { TextLegacyTest } from './TestComponents/TextLegacy';
import { TextV1Test } from './TestComponents/TextV1';
import { ThemeTest } from './TestComponents/Theme';
import { TooltipTest } from './TestComponents/Tooltip';
import { VibrancyViewTest } from './TestComponents/VibrancyView';
import * as Constants from '../../E2E/src/index.consts';

Expand Down Expand Up @@ -331,6 +332,12 @@ export const tests: TestDescription[] = [
testPageButton: Constants.HOMEPAGE_THEME_BUTTON,
platforms: ['android', 'ios', 'macos', 'win32', 'windows'],
},
{
name: 'Tooltip',
component: TooltipTest,
testPageButton: Constants.HOMEPAGE_TOOLTIP_BUTTON,
platforms: ['win32'],
},
{
name: 'Vibrancy View',
component: VibrancyViewTest,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "adding package",
"packageName": "@fluentui-react-native/e2e-testing",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "adding tests for new component",
"packageName": "@fluentui-react-native/tester",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "adding new package",
"packageName": "@fluentui-react-native/tooltip",
"email": "[email protected]",
"dependentChangeType": "patch"
}
3 changes: 3 additions & 0 deletions packages/experimental/Tooltip/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@fluentui-react-native/eslint-config-rules'],
};
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions packages/experimental/Tooltip/SPEC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Tooltip

## Background

Please write here you documentation...
1 change: 1 addition & 0 deletions packages/experimental/Tooltip/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@fluentui-react-native/scripts/babel.config');
2 changes: 2 additions & 0 deletions packages/experimental/Tooltip/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const { configureReactNativeJest } = require('@fluentui-react-native/scripts');
module.exports = configureReactNativeJest('win32');
3 changes: 3 additions & 0 deletions packages/experimental/Tooltip/just.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { preset } = require('@fluentui-react-native/scripts');

preset();
65 changes: 65 additions & 0 deletions packages/experimental/Tooltip/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "@fluentui-react-native/tooltip",
"version": "0.1.0",
"description": "A cross-platform Tooltip component for React Native.",
"main": "src/index.ts",
"module": "src/index.ts",
"typings": "lib/index.d.ts",
"onPublish": {
"main": "lib-commonjs/index.js",
"module": "lib/index.js"
},
"scripts": {
"build": "fluentui-scripts build",
"clean": "fluentui-scripts clean",
"depcheck": "fluentui-scripts depcheck",
"just": "fluentui-scripts",
"lint": "fluentui-scripts eslint",
"test": "fluentui-scripts jest",
"update-snapshots": "fluentui-scripts jest -u",
"prettier": "fluentui-scripts prettier",
"prettier-fix": "fluentui-scripts prettier --fix true"
},
"repository": {
"type": "git",
"url": "https://github.com/microsoft/fluentui-react-native.git",
"directory": "packages/experimental/Tooltip"
},
"dependencies": {
"@fluentui-react-native/callout": "^0.25.0",
"@fluentui-react-native/component-cache": "^1.6.0",
"@fluentui-react-native/framework": "0.12.0",
"tslib": "^2.3.1"
},
"devDependencies": {
"@fluentui-react-native/button": "^0.36.0",
"@fluentui-react-native/eslint-config-rules": "^0.1.1",
"@fluentui-react-native/scripts": "^0.1.1",
"@fluentui-react-native/test-tools": ">=0.1.1 <1.0.0",
"@office-iss/react-native-win32": "^0.72.0",
"@react-native/metro-config": "^0.72.0",
"react": "18.2.0",
"react-native": "^0.72.0"
},
"peerDependencies": {
"react": "18.2.0",
"react-native": "^0.72.0"
},
"author": "",
"license": "MIT",
"rnx-kit": {
"kitType": "library",
"alignDeps": {
"presets": [
"microsoft/react-native"
],
"requirements": [
"[email protected]"
],
"capabilities": [
"core",
"react"
]
}
}
}
31 changes: 31 additions & 0 deletions packages/experimental/Tooltip/src/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/** @jsxRuntime classic */
import * as React from 'react';

import { ensureNativeComponent } from '@fluentui-react-native/component-cache';
import { mergeProps, stagedComponent } from '@fluentui-react-native/framework';

import type { TooltipProps } from './Tooltip.types';
import { tooltipName } from './Tooltip.types';

const NativeTooltipView = ensureNativeComponent('RCTTooltip');

/**
* A function which determines if a set of styles should be applied to the component given the current state and props of the tooltip.
*
* @param layer The name of the state that is being checked for
* @param userProps The props that were passed into the tooltip
* @returns Whether the styles that are assigned to the layer should be applied to the tooltip
*/
export const tooltipLookup = (layer: string, userProps: TooltipProps): boolean => {
return userProps[layer];
};

export const Tooltip = stagedComponent((props: TooltipProps) => {
return (_rest: TooltipProps, children: React.ReactNode) => {
gulnazsayed marked this conversation as resolved.
Show resolved Hide resolved
return <NativeTooltipView {...mergeProps(props, _rest)}>{children}</NativeTooltipView>;
};
});

Tooltip.displayName = tooltipName;

export default Tooltip;
53 changes: 53 additions & 0 deletions packages/experimental/Tooltip/src/Tooltip.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type * as React from 'react';
import type { ViewStyle } from 'react-native';
import type { DirectionalHint } from '@fluentui-react-native/callout';

export const tooltipName = 'Tooltip';

export type TooltipProps = React.PropsWithChildren<{
/**
* The text of the tooltip.
*/
content: string;

/**
* Notification when the visibility of the tooltip is changed.
*/
onVisibleChange?: (event, data) => void;

/**
* Positioning of the tooltip relative to the target element.
*
* @default topCenter
*/
positioning?: DirectionalHint;

/**
* Allow consumers to pass in Style props
*/
style?: ViewStyle;

/**
* Target anchor that tooltip uses for relative positioning. Certain components may proffer a string as an anchor target, such as
* anchoring to a point inside the component.
*
* If not provided, will anchor to the wrapper element.
*/
target?: React.RefObject<React.Component> | string;

/**
* Controls the tooltip visibility and can be used in conjunction with onVisibleChange to modify show/hide behavior. If not provided, will be updated based on hover/focus events on target element.
*
* @default false
*/
visible?: boolean;
}>;

export interface TooltipSlotProps {
root: TooltipProps;
}

export interface TooltipType {
props: TooltipProps;
slotProps: TooltipSlotProps;
}
44 changes: 44 additions & 0 deletions packages/experimental/Tooltip/src/__tests__/Tooltip.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as React from 'react';

import { Button } from '@fluentui-react-native/experimental-button';
import { checkRenderConsistency, checkReRender } from '@fluentui-react-native/test-tools';
import * as renderer from 'react-test-renderer';

import { Tooltip } from '../Tooltip';

describe('Tooltip component tests', () => {
it('Tooltip default', () => {
const tree = renderer
.create(
<Tooltip content="Your component">
<Button>Your component</Button>
</Tooltip>,
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it('Tooltip simple rendering does not invalidate styling', () => {
checkRenderConsistency(
() => (
<Tooltip content="Default Tooltip">
<Button>Default Tooltip</Button>
</Tooltip>
),
2,
);
});

it('Tooltip re-renders correctly', () => {
checkReRender(
() => (
<Tooltip content="Render twice">
<Button>Render twice</Button>
</Tooltip>
),
2,
);
});

// Feel free to add more tests here
});
Loading
Loading