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

docs: copy as css #648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Expand Up @@ -32,3 +32,9 @@ export function filterByDesc(searchValue: string, token: TokenItem): boolean {

return containsInDesc(token.desc, needle) || containsInValue(token.value, needle);
}

export function unCamelcasify(str: string, delimeter = '-'): string {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (letter, index) => {
return `${index === 0 ? '' : delimeter}${letter.toLowerCase()}`;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import React, { FC, Fragment, useMemo } from 'react';
import type { Description, Tokens, ValueType } from '@/shared/types';

import TokensContentValue from './components/TokensContentValue';
import { filterByDesc, filterByTags } from './TokensContent.helpers';
import { filterByDesc, filterByTags, unCamelcasify } from './TokensContent.helpers';

type Props = {
tokens: Tokens;
Expand Down Expand Up @@ -80,7 +80,7 @@ const TokensContent: FC<Props> = ({ tokens, selectedTags, selectedValueType, sea
className="token-name-btn"
hoverMode="token-name-btn_hover"
stretched={!isTabletPlus}
onClick={() => copyTextToClipboard(token)}
onClick={() => copyTextToClipboard(`--vkui--${unCamelcasify(token, '_')}`)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Тут ещё нужно учитывать, что размерные токены бывают с постфиксом --compact и --regular

>
{token}
</Button>
Expand Down