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

Revert "feat: add skip to content on panel and story iframe" #11718

Merged
merged 1 commit into from
Jul 29, 2020
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
2 changes: 0 additions & 2 deletions lib/ui/src/components/preview/FramesRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Global, CSSObject } from '@storybook/theming';
import { IFrame } from './iframe';
import { FramesRendererProps } from './utils/types';
import { stringifyQueryParams } from './utils/stringifyQueryParams';
import { SkipToContent } from '../sidebar/Tree/ListItem';

const getActive = (refId: FramesRendererProps['refId']) => {
if (refId) {
Expand Down Expand Up @@ -75,7 +74,6 @@ export const FramesRenderer: FunctionComponent<FramesRendererProps> = ({
<Global styles={styles} />
{Object.entries(frames).map(([id, src]) => (
<Fragment key={id}>
<SkipToContent href={`#${storyId}`}>Go back to navigation</SkipToContent>
<IFrame
active={id === active}
key={refs[id] ? refs[id].url : id}
Expand Down
5 changes: 0 additions & 5 deletions lib/ui/src/components/sidebar/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { styled } from '@storybook/theming';

import { Brand } from './Brand';
import { SidebarMenu, MenuList } from './Menu';
import { SkipToContent } from './Tree/ListItem';

export interface HeadingProps {
menuHighlighted?: boolean;
Expand Down Expand Up @@ -40,12 +39,8 @@ export const Heading: FunctionComponent<HeadingProps & ComponentProps<typeof Hea
menu,
...props
}) => {
const selectedStoryId = global.location.href.split('story/')[1];
return (
<HeadingWrapper {...props}>
{selectedStoryId && (
<SkipToContent href={`#${selectedStoryId}`}>Go to selected story</SkipToContent>
)}
<BrandArea>
<Brand />
</BrandArea>
Expand Down
51 changes: 7 additions & 44 deletions lib/ui/src/components/sidebar/Tree/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,36 +65,6 @@ const Icon = styled(Icons)<IconProps>(
isSelected ? { color: 'inherit', fontWeight: theme.typography.weight.bold } : {}
);

export const ItemContainer = styled.div({
position: 'relative',
});

export const SkipToContent = styled.a(({ theme }) => ({
fontSize: theme.typography.size.s2,
background: theme.background.app,
position: 'absolute',
textDecoration: 'none',
lineHeight: '16px',
padding: 3,
right: 2,
top: 2,
zIndex: 2,
'&:visited': {
color: 'inherit',
},
'&:not(:focus)': {
position: 'absolute',
width: 1,
height: 1,
padding: 0,
margin: -1,
overflow: 'hidden',
clip: 'rect(0, 0, 0, 0)',
whiteSpace: 'nowrap',
border: 0,
},
}));

export const Item = styled.a<{
depth?: number;
isSelected?: boolean;
Expand Down Expand Up @@ -179,20 +149,13 @@ export const ListItem: FunctionComponent<ListItemProps> = ({
[className, isSelected]
);

const shouldShowSkipLink = isLeaf && isSelected;

return (
<ItemContainer>
<Item isSelected={isSelected} depth={depth} {...props} className={classes} id={id}>
{!isLeaf ? (
<Expander className="sidebar-expander" depth={depth} isExpanded={isExpanded} />
) : null}
<Icon className="sidebar-svg-icon" icon={iconName} isSelected={isSelected} />
<span>{name}</span>
</Item>
{shouldShowSkipLink && (
<SkipToContent href="#storybook-preview-iframe">Jump to story</SkipToContent>
)}
</ItemContainer>
<Item isSelected={isSelected} depth={depth} {...props} className={classes} id={id}>
{!isLeaf ? (
<Expander className="sidebar-expander" depth={depth} isExpanded={isExpanded} />
) : null}
<Icon className="sidebar-svg-icon" icon={iconName} isSelected={isSelected} />
<span>{name}</span>
</Item>
);
};