- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1
 
feat: improve styling for library pages #28
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
1e428a7
              d6f67aa
              13502c2
              1162d7c
              2c9507b
              c15054b
              d80ee0e
              9d3ff65
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -40,7 +40,9 @@ export const CategoryTemplate: FC<CategoryTemplateProps> = ({ | |
| {item.code ? <code>{item.name}</code> : item.name} | ||
| </a> | ||
| </div> | ||
| <div class="pl-4">{item.oneliner}</div> | ||
| <div> | ||
| <p>{item.oneliner}</p> | ||
| </div> | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the original style looks better. It weakens  Example: https://typst-docs-web.netlify.app/en-us-v0.14.0/reference/foundations/ Besides, it might be possible to unify the style here in  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I simply aligned the elements horizontally while respecting the styles of   
diff --git a/src/components/templates/CategoryTemplate.tsx b/src/components/templates/CategoryTemplate.tsx
index a0e777a..05ecbeb 100644
--- a/src/components/templates/CategoryTemplate.tsx
+++ b/src/components/templates/CategoryTemplate.tsx
@@ -32,16 +32,16 @@ export const CategoryTemplate: FC<CategoryTemplateProps> = ({
 					<h2 id="definitions">
 						<Translation translationKey="definitions" />
 					</h2>
-					<ul class="subgridded">
+					<ul>
 						{page.body.content.items.map((item) => (
 							<li key={item.route}>
-								<div>
-									<a href={item.route}>
-										{item.code ? <code>{item.name}</code> : item.name}
-									</a>
-								</div>
-								<div>
-									<p>{item.oneliner}</p>
+								<div class="flex">
+									<div class="min-w-[8rem]">
+										<a href={item.route}>
+											{item.code ? <code>{item.name}</code> : item.name}
+										</a>
+									</div>
+									<div>{item.oneliner}</div>
 								</div>
 							</li>
 						))}There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That looks nice!  | 
||
| </li> | ||
| ))} | ||
| </ul> | ||
| 
          
            
          
           | 
    ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -69,16 +69,18 @@ export const FuncTemplate: FC<FuncTemplateProps> = ({ | |
| } | ||
| })} | ||
| 
     | 
||
| <h2 id="parameters" class="flex items-baseline gap-1"> | ||
| <Translation translationKey="parameters" /> | ||
| <Tooltip kind="parameters" /> | ||
| <h2 id="parameters" class="flex"> | ||
| <div class="flex items-baseline gap-1"> | ||
| <Translation translationKey="parameters" /> | ||
| <Tooltip kind="parameters" /> | ||
| </div> | ||
| </h2> | ||
| 
     | 
||
| <div class="mb-6"> | ||
| <div class="my-4"> | ||
| <FunctionDefinition func={content} /> | ||
| </div> | ||
| 
     | 
||
| <div class="my-6"> | ||
| <div class="my-4"> | ||
| <FunctionParameters params={content.params} /> | ||
| </div> | ||
| 
     | 
||
| 
          
            
          
           | 
    @@ -109,48 +111,47 @@ function ScopedDefinitions({ | |
| // the following heading levels will _not_ increase with the scope level. | ||
| return ( | ||
| <div class="mt-8"> | ||
| <h2 id={`${parentId}definitions`} class="flex items-baseline gap-1"> | ||
| {parent ? ( | ||
| // Currently, the scope has at most two levels. | ||
| // Therefore, it is sufficient to only annotate the direct `parent`. | ||
| <Translation translationKey="definitionsOf" name={parent.name} /> | ||
| ) : ( | ||
| <Translation translationKey="definitions" /> | ||
| )} | ||
| <Tooltip kind="definitions" /> | ||
| <h2 id={`${parentId}definitions`} class="flex"> | ||
| <div class="flex items-baseline gap-1"> | ||
| {parent ? ( | ||
| // Currently, the scope has at most two levels. | ||
| // Therefore, it is sufficient to only annotate the direct `parent`. | ||
| <Translation translationKey="definitionsOf" name={parent.name} /> | ||
| ) : ( | ||
| <Translation translationKey="definitions" /> | ||
| )} | ||
| <Tooltip kind="definitions" /> | ||
| </div> | ||
| </h2> | ||
| 
     | 
||
| {scope.map((method, _index) => { | ||
| const methodId = `${parentId}definitions-${method.name}`; | ||
| 
     | 
||
| return ( | ||
| <div | ||
| key={method.name} | ||
| class="mb-8 pb-6 border-b border-gray-100 last:border-0" | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you've removed the border.  
↓ After the removal,  I suggest adding the border back. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We plan to add decorative elements to the headings, so we will put this proposal on hold.  | 
||
| > | ||
| <h3 id={methodId} class="method-head mb-3 flex items-center gap-2"> | ||
| <code | ||
| class="text-base font-medium" | ||
| style={ | ||
| normalizeDeprecation(method) !== null | ||
| ? { textDecoration: "line-through" } | ||
| : undefined | ||
| } | ||
| > | ||
| {method.name} | ||
| </code> | ||
| 
     | 
||
| <small class="flex items-center"> | ||
| {method.element && <Tooltip kind="element" />} | ||
| {method.contextual && <Tooltip kind="contextual" />} | ||
| </small> | ||
| <div key={method.name}> | ||
| <h3 id={methodId} class="flex"> | ||
| <div class="flex items-center gap-2"> | ||
| <code | ||
| class="text-base font-medium" | ||
| style={ | ||
| normalizeDeprecation(method) !== null | ||
| ? { textDecoration: "line-through" } | ||
| : undefined | ||
| } | ||
| > | ||
| {method.name} | ||
| </code> | ||
| 
     | 
||
| <small class="flex items-center"> | ||
| {method.element && <Tooltip kind="element" />} | ||
| {method.contextual && <Tooltip kind="contextual" />} | ||
| </small> | ||
| </div> | ||
| </h3> | ||
| 
     | 
||
| {<DeprecationWarning item={method} level="scoped" />} | ||
| 
     | 
||
| <div class="pl-2"> | ||
| <FunctionDisplay func={method} prefix={methodId} /> | ||
| </div> | ||
| <FunctionDisplay func={method} prefix={methodId} /> | ||
| 
     | 
||
| <ScopedDefinitions | ||
| scope={method.scope} | ||
| 
          
            
          
           | 
    ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -20,27 +20,26 @@ export const FunctionDefinition: FC<FunctionDefinitionProps> = ({ | |
| func, | ||
| prefix = undefined, | ||
| }) => { | ||
| const funcName = func.self ? "self" : genPath(func); | ||
| return ( | ||
| <div class="bg-gray-50 p-4 rounded-md border border-gray-100 overflow-x-auto"> | ||
| <div class="code code-definition font-mono text-base"> | ||
| <span class="text-gray-500">{func.self ? "self." : genPath(func)}</span> | ||
| <span class="typ-func font-semibold text-blue-500">{func.name}</span> | ||
| <span class="text-gray-700">(</span> | ||
| <div class="arguments pl-4 md:pl-6 flex flex-col"> | ||
| <pre> | ||
| <code> | ||
| <span>{funcName}</span> | ||
| {funcName !== "" && <span class="typ-punct">.</span>} | ||
                
       | 
||
| <span class="typ-func">{func.name}</span> | ||
| <span class="typ-punct">(</span> | ||
| <span class="arguments pl-4 md:pl-6 flex flex-col"> | ||
| {func.params.map((param, index) => ( | ||
| <div | ||
| <span | ||
| key={param.name} | ||
| class="overview-param flex flex-row items-center py-0.5" | ||
| > | ||
| {!param.positional && ( | ||
| <div class="flex-shrink-0"> | ||
| <a | ||
| href={`#${buildParamId(param.name, prefix)}`} | ||
| class="text-gray-800 hover:text-blue-500 transition-colors mr-1" | ||
| > | ||
| <span class="font-medium">{param.name}</span> | ||
| <span class="text-gray-500">:</span> | ||
| <div class="flex-shrink-0 mr-1"> | ||
| <a href={`#${buildParamId(param.name, prefix)}`}> | ||
| <span>{param.name}</span> | ||
| </a> | ||
| <span class="typ-punct">:</span> | ||
| </div> | ||
| )} | ||
| <div class="flex flex-row flex-wrap gap-1"> | ||
| 
        
          
        
         | 
    @@ -58,38 +57,34 @@ export const FunctionDefinition: FC<FunctionDefinitionProps> = ({ | |
| })} | ||
| </div> | ||
| {index < func.params.length - 1 && ( | ||
| <span class="text-gray-500 ml-1">,</span> | ||
| <span class="typ-punct">,</span> | ||
                
      
                  3w36zj6 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| )} | ||
| </div> | ||
| </span> | ||
| ))} | ||
| </div> | ||
| <span class="text-gray-700">)</span> | ||
| </span> | ||
| 
     | 
||
| <span class="typ-punct">)</span> | ||
| 
     | 
||
| {func.returns.length > 0 && ( | ||
| <> | ||
| <span class="text-gray-500 mx-1">-></span> | ||
| <div class="inline-flex flex-wrap gap-1"> | ||
| {func.returns.map((ret, i) => { | ||
| <span class="typ-op mx-1">-></span> | ||
| <div class="inline-flex flex-wrap gap-1 py-0.5"> | ||
| {func.returns.map((ret, _) => { | ||
| const href = type2href(ret); | ||
| return ( | ||
| <> | ||
| <TypeIcon | ||
| key={ret} | ||
| type={ret} | ||
| href={ | ||
| href ? joinPath(basePath, "reference", href) : undefined | ||
| } | ||
| /> | ||
| {i < func.returns.length - 1 && ( | ||
| <span class="text-gray-500 mx-1">,</span> | ||
| )} | ||
| </> | ||
| <TypeIcon | ||
| key={ret} | ||
| type={ret} | ||
| href={ | ||
| href ? joinPath(basePath, "reference", href) : undefined | ||
| } | ||
| /> | ||
| ); | ||
| })} | ||
| </div> | ||
| </> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </code> | ||
| </pre> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -32,7 +32,7 @@ export const FunctionDisplay: FC<FunctionDisplayProps> = ({ | |
| case "example": | ||
| return isExampleFolding ? ( | ||
| <details class="folding-example group"> | ||
| <summary class="flex items-center gap-1 text-sm font-medium text-blue-600 cursor-pointer hover:text-blue-800"> | ||
| <summary class="flex items-center gap-1 text-sm font-medium cursor-pointer text-gray-600 hover:text-gray-800 transition-colors"> | ||
| <div class="w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90"> | ||
| <ChevronRightIcon /> | ||
| </div> | ||
| 
        
          
        
         | 
    @@ -41,14 +41,12 @@ export const FunctionDisplay: FC<FunctionDisplayProps> = ({ | |
| title={block.content.title} | ||
| /> | ||
| </summary> | ||
| <div class="mt-2 bg-white p-3 rounded-md border border-gray-200 text-sm"> | ||
| <div class="my-4"> | ||
                
       | 
||
| <HtmlContent html={block.content.body} /> | ||
| </div> | ||
| </details> | ||
| ) : ( | ||
| <div class="bg-gray-50 p-4 rounded-md border border-gray-200"> | ||
| <HtmlContent html={block.content.body} /> | ||
| </div> | ||
| <HtmlContent html={block.content.body} /> | ||
| ); | ||
| default: | ||
| return null; | ||
| 
          
            
          
           | 
    ||





Uh oh!
There was an error while loading. Please reload this page.