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

[hackathon-2024]: Add Component Selector to storybook #32865

Open
wants to merge 113 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
1d4b550
Initial commit for Component Selector
adamsamec Sep 11, 2023
86e77de
initial decision tree
kolaps33 Sep 11, 2023
16dd110
Proper nesting in conditional rendering
adamsamec Sep 11, 2023
4ea181f
create method updateDecisionProps
kolaps33 Sep 12, 2023
1499616
fix types
kolaps33 Sep 12, 2023
15a6609
adding jsons
kolaps33 Sep 12, 2023
f9ede7c
adding styles + change to radiogroup
kolaps33 Sep 12, 2023
41962bf
import jsons, merging base objects
kolaps33 Sep 12, 2023
8e779a0
Refactor multiple decision states into single object state and fix er…
adamsamec Sep 12, 2023
56923c5
Do not include interactive and composition decisions in the selected …
adamsamec Sep 12, 2023
674d78a
Add navigation by decision
adamsamec Sep 12, 2023
9d96ca2
getComponent update JSONS
kolaps33 Sep 12, 2023
0a80ea9
fix adding prop from radio
kolaps33 Sep 13, 2023
ff30825
removing composition
kolaps33 Sep 13, 2023
10d4d3a
amend jsons add static or interactive
kolaps33 Sep 13, 2023
068fec3
adding interactivity to decisions array
kolaps33 Sep 13, 2023
ab45763
Fix filtering of interactive/static components
adamsamec Sep 13, 2023
7dc49cd
Group checkboxes into group role
adamsamec Sep 13, 2023
6eed75e
Clear decisions from the same category upon radio selection
adamsamec Sep 13, 2023
399eec6
fix category, adding more components jsons
kolaps33 Sep 13, 2023
17063ca
last fixes to get category
kolaps33 Sep 14, 2023
f8aa74d
add label for checkboxes, add number of found comp
kolaps33 Sep 14, 2023
91ac0e2
add weight for heading
kolaps33 Sep 14, 2023
d169a18
adding margin for found text
kolaps33 Sep 14, 2023
3082b47
fix typo in list
kolaps33 Sep 14, 2023
55a90ee
adding components constant
kolaps33 Sep 14, 2023
e7048bc
Merge branch 'master' into adamsamec/component-selector
Sep 16, 2024
e4c5175
Add component example URL retrieval function
Sep 16, 2024
bab3cf9
Retrieve default example when no example is given
Sep 17, 2024
a3eef07
adding according and component selector grid
mituron Sep 17, 2024
a02f15b
Reformat JSON component definitions, add attributes and questions
Sep 18, 2024
4715ebc
Merge branch 'adamsamec/component-selector' of https://github.com/ada…
Sep 18, 2024
b096caf
Use new names of component definitions
Sep 18, 2024
e8bb36c
fix name of table base
mituron Sep 18, 2024
9af45d4
amending headings
mituron Sep 18, 2024
7de3af0
amending headings of second accordion
mituron Sep 18, 2024
891f3cc
Restructure groups and questions
Sep 18, 2024
76243c4
fix merging of attribute between child and base JSON
mituron Sep 18, 2024
8844e1b
Add attributes to components definitions from questions
Sep 18, 2024
3389d02
Merge branch 'adamsamec/component-selector' of https://github.com/ada…
Sep 18, 2024
d5043ef
show components in results where are selected
mituron Sep 18, 2024
af10011
change URL to production, amend link creation in utils
mituron Sep 18, 2024
4d3587b
Add folder for components defs and generate proper URL
Sep 18, 2024
6a49974
Adding questionnaire to Selector | Removed duplicate Selector page | …
hanys7 Sep 18, 2024
a5f18f3
removing according, behaviour section started
mituron Sep 18, 2024
fff8928
adding behaviours toggle buttons
mituron Sep 18, 2024
d3b766a
removing radio and adding toggle buttons
mituron Sep 19, 2024
0ef7583
fix wrong import
mituron Sep 19, 2024
289a884
Merge branch 'master' into adamsamec/component-selector
Sep 19, 2024
ab50b19
Changes in component def attributes
Sep 19, 2024
2e97359
dipslay questions based on the logic
mituron Sep 19, 2024
fe8ed88
Add InfoLabel and Tooltip definitions and fixes
Sep 19, 2024
e406446
Merge branch 'adamsamec/component-selector' of https://github.com/ada…
Sep 19, 2024
24f49fe
Removed questions annotation from json files, generate numbering base…
hanys7 Sep 19, 2024
11ba4fe
trying to fix radio state logic do not work still
mituron Sep 19, 2024
73cf139
trying to fix radio state logic do not work still
mituron Sep 19, 2024
b38fe68
clean up
mituron Sep 19, 2024
053589d
Added image for UI types, fixed UI for input selections, used selecta…
hanys7 Sep 20, 2024
b71a37c
trying to fix displaying components after selection
mituron Sep 22, 2024
6f51a67
changes to add component into array
mituron Sep 24, 2024
f4ef707
fix questions radio
mituron Oct 5, 2024
674d327
remove unused code, add questions heading
mituron Dec 2, 2024
6f2152c
Change folder structure
Dec 10, 2024
e634d5d
Add categories json
Dec 10, 2024
7a01e57
change import all JSONs in one
mituron Dec 10, 2024
6c45608
Add selection from categories logic
Dec 10, 2024
e80cdf8
fix for pushing into field
mituron Dec 10, 2024
782acc4
Add components filter feature
Dec 11, 2024
e49a82e
Small refactoring
Dec 11, 2024
057125d
Fix typ errors
Dec 11, 2024
842f180
Fix type error
Dec 11, 2024
75313c6
Small refactoring
Dec 11, 2024
2180e1b
Rename vars and functions
Dec 11, 2024
175d803
Extract MatchingComponents into React component in separate file
Dec 11, 2024
dcb276a
Small refactoring
Dec 11, 2024
7c34446
amend suitable components logic
mituron Dec 12, 2024
969e71f
Extract BehaviorSelection component and refactor
Dec 12, 2024
aa544c2
Move behaviorOptions to JSON file
Dec 12, 2024
f71298e
Refactor mainly keys in Reacgt mappings
Dec 12, 2024
937e7a5
Refactor and fix keys
Dec 16, 2024
93054a9
Add aria-labelledby for radio groups
Dec 16, 2024
e0eb96c
Rename variables
Dec 16, 2024
4da4f21
fix checkbox name
mituron Dec 16, 2024
2be1aed
Apply filter also to story names
Dec 16, 2024
f198a12
Add number of components available
Dec 16, 2024
d7f7b8b
Add number of matching components to heading
Dec 16, 2024
fb1e1be
Improve alt text for component card images
Dec 17, 2024
40190b4
Load component images from file based on component name rather than J…
Dec 17, 2024
9d12fdb
Small refactor for fully matching
Dec 17, 2024
7f9e0e8
Fix component name and story in matching components list
Dec 17, 2024
ca4f55d
Remove some unused imports
Dec 17, 2024
9f37ab2
Separate functionality into two modes
Dec 17, 2024
3414556
Fix lint errors and refactor
Dec 17, 2024
598dfef
Refactor function into useEffect
Jan 2, 2025
ca0f5fb
adding images from Kay
mituron Jan 6, 2025
d5bd244
import rest of missing component picture, preview
mituron Jan 6, 2025
6f088f2
Fix TabList.png file name
Jan 6, 2025
15b703c
Reset form when mode changes
Jan 6, 2025
aa2d92c
Fix some filtering bugs
Jan 6, 2025
462f2ac
Fix component selection but still bugs with component removal
Jan 6, 2025
f1c2b80
Fix updating matching components after deselecting components
Jan 7, 2025
4dab3e3
sending as welll state selected
mituron Jan 7, 2025
71ebb03
Fix Tag display
Jan 7, 2025
d5020c6
Fix cards selected state display and small refactoring
Jan 7, 2025
01b2f81
Selected components tags now work and added remove all components button
Jan 7, 2025
ae4bedc
Add link to skip to questions section
Jan 7, 2025
7649060
Focus first accordion button on last tag removal
Jan 7, 2025
73b1871
Refactor matching components into useMemo
Jan 7, 2025
9443182
removing tablist png
mituron Jan 8, 2025
864f714
adding tabList png
mituron Jan 8, 2025
021f0d9
Matching components heading and message changes
Jan 8, 2025
6b1adc1
adjust UI
mituron Jan 8, 2025
cec6116
Merge branch 'adamsamec/component-selector' of https://github.com/ada…
mituron Jan 8, 2025
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Accordion",
"component": "Accordion",
"attributes": ["expandable", "tabbable", "navigationByTabKey", "interactive"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "ButtonBase",
"attributes": ["staysOnPage", "navigationByTabKey", "interactive"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Checkbox",
"component": "Checkbox",
"attributes": ["yesOrNo", "notInsideMenu", "navigationByTabKey", "interactive"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"tags": ["Button", "Link", "SplitButton", "ToggleButton"],
"questions": ["hasMoreActions", "doesNavigateToPage"]
},
{
"tags": ["Checkbox", "Radio", "ToggleButton", "MenuItemCheckbox", "MenuItemRadio"],
"questions": ["isYesOrNo", "isInsideMenu"]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Link",
"component": "Link",
"attributes": ["singleAction", "navigatesToPage", "navigationByTabKey", "interactive"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "List",
"component": "List",
"extends": "ListBase",
"attributes": ["static"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "ListBase",
"attributes": ["narratesPosition", "singleColumn"],
"note": "Component not available yet, under development."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ListSingleAction",
"component": "List",
"story": "Single Action",
"extends": "ListBase",
"attributes": ["interactive", "navigationByArrowKeys"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Menu",
"component": "Menu",
"folder": "Menu",
"extends": "MenuBase"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "MenuBase",
"attributes": ["insideMenu", "navigationByArrowKeys", "narratesPosition", "interactive"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "MenuButton",
"component": "MenuButton",
"folder": "Button",
"extends": "ButtonBase",
"attributes": ["opensMenu"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "MenuItemCheckbox",
"component": "Menu",
"folder": "Menu",
"story": "Checkbox Items",
"extends": "MenuBase",
"attributes": ["yesOrNo"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "MenuItemRadio",
"component": "Menu",
"folder": "Menu",
"story": "Radio Items",
"extends": "MenuBase",
"attributes": ["notYesOrNo"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "MenuSubmenu",
"component": "Menu",
"folder": "Menu",
"story": "Nested Submenus",
"extends": "MenuBase",
"attributes": ["nested"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{
"id": "hasMoreActions",
"question": "Does component have more actions?",
"selectText": "Question 1",
"shortSelectText": "Q1:",
"answers": [
{
"value": "moreActions",
"text": "Yes"
},
{
"value": "singleAction",
"text": "No"
}
]
},
{
"id": "doesNavigateToPage",
"question": "Does component navigate to new page?",
"selectText": "Question 2",
"shortSelectText": "Q2:",
"answers": [
{
"value": "navigatesToPage",
"text": "Yes"
},
{
"value": "staysOnPage",
"text": "No"
}
]
},
{
"id": "isYesOrNo",
"question": "Is toggle or choice possible between yes or no?",
"selectText": "Question 3",
"shortSelectText": "Q3:",
"answers": [
{
"value": "yesOrNo",
"text": "Yes"
},
{
"value": "notYesOrNo",
"text": "No"
}
]
},
{
"id": "isInsideMenu",
"question": "Is component inside menu?",
"selectText": "Question 4",
"shortSelectText": "Q4:",
"answers": [
{
"value": "insideMenu",
"text": "Yes"
},
{
"value": "notInsideMenu",
"text": "No"
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "SplitButton",
"component": "SplitButton",
"folder": "Button",
"extends": "ButtonBase",
"attributes": ["moreActions"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "TabList",
"component": "TabList",
"attributes": ["interactive", "navigationByArrowKeys", "narratesPosition"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Table",
"component": "Table",
"extends": "TableBase",
"attributes": ["static"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "TableBase",
"attributes": ["columnsAndRows", "narratesPosition"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "TableCellActions",
"component": "Table",
"story": "Cell Actions",
"extends": "TableBase",
"attributes": ["interactive", "navigationByTabKey"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "TableCellNavigation",
"component": "Table",
"story": "Cell Navigation",
"extends": "TableBase",
"attributes": ["interactive", "navigationByArrowKeys"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Text",
"component": "Text",
"attributes": ["textOrHeading", "static"],
"note": "Use the 'as' prop to change text to heading."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ToggleButton",
"component": "ToggleButton",
"folder": "Button",
"extends": "ButtonBase",
"attributes": ["singleAction", "yesOrNo"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Tree",
"component": "Tree",
"extends": "TreeBase"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "TreeBase",
"attributes": ["interactive", "navigationByArrowKeys", "hierarchical", "narratesPosition"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "TreeSelection",
"component": "Tree",
"story": "Selection",
"extends": "TreeBase",
"attributes": ["toggle"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export { default as AccordionDef } from './Accordion.json';
export { default as TextDef } from './Text.json';
export { default as LinkDef } from './Link.json';
export { default as CheckboxDef } from './Checkbox.json';

export { default as TableBaseDef } from './TableBase.json';
export { default as TableDef } from './Table.json';
export { default as TableCellActionsDef } from './TableCellActions.json';
export { default as TableCellNavigationDef } from './TableCellNavigation.json';

export { default as MenuBaseDef } from './MenuBase.json';
export { default as MenuDef } from './Menu.json';
export { default as MenuItemCheckboxDef } from './MenuItemCheckbox.json';
export { default as MenuItemRadioDef } from './MenuItemRadio.json';
export { default as MenuSubmenuDef } from './MenuSubmenu.json';

export { default as ButtonBaseDef } from './ButtonBase.json';
export { default as SplitButtonDef } from './SplitButton.json';
export { default as ToggleButtonDef } from './ToggleButton.json';
export { default as MenuButtonDef } from './MenuButton.json';

export { default as ListBaseDef } from './ListBase.json';
export { default as ListDef } from './List.json';
export { default as ListSingleActionDef } from './ListSingleAction.json';

export { default as TreeBaseDef } from './TreeBase.json';
export { default as TreeDef } from './Tree.json';
export { default as TreeSelectionDef } from './TreeSelection.json';

export { default as TabListDef } from './TabList.json';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Meta, Canvas } from '@storybook/addon-docs';
import { Selector } from './Selector.stories';
export const parentPath = 'concepts-developer-tools-stories';

<Meta title="Concepts/Developer/Tools/Stories/Component Selector" />

<h1 class="sbdocs-title"> Component Selector </h1>

<Canvas withSource="none">
<Selector />
</Canvas>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as React from 'react';

const APP_TITLE = 'Component Selector';
const APP_TITLE_SEPARATOR = ' | ';
const formatComponentStoryUrl = (component, story) =>
`https://react.fluentui.dev/?path=/docs/components-${component}--docs#${story}`;

interface FullscreenLinkProps {
parent: string;
story: string;
content: string;
}

// https://storybook.js.org/addons/@storybook/addon-links does not allow opening a story in new tab
// so this is a naive attempt for opening a story in full screen
export const FullscreenLink = (props: FullscreenLinkProps) => (
<a className="sbdocs sbdocs-a" href={`iframe.html?id=${props.parent}--${props.story}`} target="_blank">
{props.content}
</a>
);

export const ScenariosListLink: React.FC = props => (
<a
className="sbdocs sbdocs-a"
href={`iframe.html?id=concepts-developer-accessibility-stories-list-of-scenarios--page`}
>
{props.children}
</a>
);

export const BackLink = () => <ScenariosListLink>Go back to main menu</ScenariosListLink>;

export const Scenario: React.FC<{ pageTitle: string }> = ({ pageTitle, children }) => {
React.useEffect(() => {
document.title = pageTitle + APP_TITLE_SEPARATOR + APP_TITLE;
}, [pageTitle]);

return (
<div role="main">
<BackLink />
<br />
{children}
</div>
);
};

export const removeFromArray = (array: string[], item: string) => {
const index = array.indexOf(item);
if (index >= 0) {
array.splice(index, 1);
}
};

const camelToDashed = camel => {
const dashed = camel.toLowerCase().replace(/\ |\:/g, '-');
return dashed;
};

export const getComponentStoryUrl = component => {
const camelComponent = component.folder ? component.folder + ' ' + component.component : component.component;
const dashedComponent = camelToDashed(camelComponent);
const dashedStory = component.story ? camelToDashed(component.story) : 'default';
const url = formatComponentStoryUrl(dashedComponent, dashedStory);
return url;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import { Colors } from './ThemeColors.stories.tsx';
<h1 class="sbdocs-title"> Colors </h1>

<Canvas withSource="none">
<span>test</span>
<Colors />
</Canvas>
Loading