Skip to content

Commit

Permalink
Merge 7a56ae7 into ff9905f
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored Sep 30, 2024
2 parents ff9905f + 7a56ae7 commit bc82bcf
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-walls-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/primitives': minor
---

Adding diffBlob tokens
73 changes: 73 additions & 0 deletions docs/storybook/stories/Demo/Diff/Diff.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
:root {
--line-number-cell-width: 40px;
--diff-line-minimum-height: 24px;
--diff-line-height: 24px;
--diff-action-bar-position: 0;
}
* {
box-sizing: border-box;
}
.diff-line {
--diff-num-bg: var(--diffBlob-hunk-bgColor-num-rest);
--diff-num-fg: var(--diffBlob-hunk-fgColor-num-rest);
--diff-line-bg: var(--diffBlob-hunk-bgColor-line);
--diff-line-fg: var(--diffBlob-hunk-fgColor-text);
&.type-addition {
--diff-num-bg: var(--diffBlob-addition-bgColor-num);
--diff-num-fg: var(--diffBlob-addition-fgColor-num);
--diff-line-bg: var(--diffBlob-addition-bgColor-line);
--diff-line-fg: var(--diffBlob-addition-fgColor-text);
}
&.type-deletion {
--diff-num-bg: var(--diffBlob-deletion-bgColor-num);
--diff-num-fg: var(--diffBlob-deletion-fgColor-num);
--diff-line-bg: var(--diffBlob-deletion-bgColor-line);
--diff-line-fg: var(--diffBlob-deletion-fgColor-text);
}
border-spacing: 0;
border-collapse: collapse;
.diff-line-number {
width: 1%;
min-width: 50px;
line-height: 100%;
padding-right: var(--base-size-8, 8px) !important;
text-align: right;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
background-color: var(--diff-num-bg);
color: var(--diffBlob-hunk-fgColor-num-rest);
code {
line-height: var(--diff-line-height);
}
}
&.type-hunk {
.diff-line-number {
&:hover {
background-color: var(--diffBlob-hunk-bgColor-num-hover);
color: var(--diffBlob-hunk-fgColor-num-hover);
}
}
}
.diff-text-cell {
position: relative;
padding-right: var(--diff-line-height);
padding-left: var(--diff-line-height);
background-color: var(--diff-line-bg);
code {
span {
color: var(--diff-line-fg);
overflow: hidden;
word-wrap: break-word;
white-space: pre-wrap;
}
}
}
code {
font-family: var(--fontStack-monospace, ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace);
font-size: 12px;
background-color: transparent;
padding: 0;
vertical-align: middle;
}
}
52 changes: 52 additions & 0 deletions docs/storybook/stories/Demo/Diff/Diff.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react'
import './Diff.css'
import {Box} from '@primer/react'

export default {
title: 'Testing/Diff',
parameters: {
controls: {hideNoControlsWarning: true},
options: {
showPanel: false,
},
},
}

type DiffLineType = 'hunk' | 'addition' | 'deletion'

const DiffLine = ({
lineNumber = 11,
text = '// TODO: 1234 example line',
type = 'hunk',
}: {
lineNumber?: number
text?: string
type?: DiffLineType
}) => {
return (
<table width="100%" className={`diff-line type-${type}`}>
<tbody>
<tr>
<td aria-label={`Line ${lineNumber}`} data-line-number="true" className="diff-line-number" colSpan={1}>
<code>{lineNumber}</code>
</td>
<td className="diff-text-cell">
<code>
<span>{text}</span>
</code>
</td>
</tr>
</tbody>
</table>
)
}

export const Diff = () => {
return (
<Box>
<DiffLine />
<DiffLine type="addition" />
<DiffLine type="deletion" />
</Box>
)
}
71 changes: 68 additions & 3 deletions src/tokens/functional/color/light/app-light.json5
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,49 @@
},
},
hunk: {
bgColor: {
fgColor: {
text: {
$value: '{fgColor.muted}',
$type: 'color',
$extensions: {
'org.primer.figma': {
collection: 'mode',
mode: 'light',
group: 'component',
scopes: ['fgColor'],
},
},
},
num: {
$value: '{base.color.blue.3}',
rest: {
$value: '{fgColor.default}',
$type: 'color',
$extensions: {
'org.primer.figma': {
collection: 'mode',
mode: 'light',
group: 'component',
scopes: ['fgColor'],
},
},
},
hover: {
$value: '{fgColor.onEmphasis}',
$type: 'color',
$extensions: {
'org.primer.figma': {
collection: 'mode',
mode: 'light',
group: 'component',
scopes: ['fgColor'],
},
},
},
},
},
bgColor: {
line: {
$value: '{bgColor.accent.muted}',
$type: 'color',
$extensions: {
'org.primer.figma': {
Expand All @@ -196,7 +236,32 @@
scopes: ['bgColor'],
},
},
alpha: 0.4,
},
num: {
rest: {
$value: '{base.color.blue.1}',
$type: 'color',
$extensions: {
'org.primer.figma': {
collection: 'mode',
mode: 'light',
group: 'component',
scopes: ['bgColor'],
},
},
},
hover: {
$value: '{bgColor.accent.emphasis}',
$type: 'color',
$extensions: {
'org.primer.figma': {
collection: 'mode',
mode: 'light',
group: 'component',
scopes: ['bgColor'],
},
},
},
},
},
},
Expand Down

0 comments on commit bc82bcf

Please sign in to comment.