@platformatic/ui-components 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@platformatic/ui-components",
3
3
  "description": "Platformatic UI Components",
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "scripts": {
@@ -4,7 +4,7 @@ import ApiFooter from './Api/Footer'
4
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
5
5
  import { faLink } from '@fortawesome/free-solid-svg-icons'
6
6
  import ApiVersion from './Api/Version'
7
- import ApiIcon from './Api/ApiIcon'
7
+ import ApiIcon from './icons/ApiIcon'
8
8
  import ApiIconClosed from './Api/ApiIconClosed'
9
9
  import Separator from './VerticalSeparator'
10
10
  import ApiStatus from './Api/Status'
@@ -36,11 +36,7 @@ export default function ApiSummary (props) {
36
36
  <div className='flex items-center justify-between'>
37
37
  <div className='flex items-center justify-between gap-4'>
38
38
  <ApiName name={name} />
39
- <span>
40
- <a href='#' className='border p-2 rounded-full'>
41
- <FontAwesomeIcon color='white' icon={faLink} />
42
- </a>
43
- </span>
39
+ <span><FontAwesomeIcon color='white' icon={faLink} /></span>
44
40
  <ApiVersion version={version} />
45
41
  </div>
46
42
  <div className={styles.status}>
@@ -4,7 +4,7 @@ import SearchBar from './SearchBar'
4
4
  import Api from './Api'
5
5
  import ApiDetails from './ApiDetail'
6
6
  import TabbedWindow from './TabbedWindow'
7
- import Prs from './Pr'
7
+ import Prs from './PullRequest'
8
8
  import Playground from './Playground'
9
9
  import Versions from './Versions'
10
10
  import React, { useState } from 'react'
@@ -0,0 +1,36 @@
1
+ 'use strict'
2
+ import React from 'react'
3
+ import BorderedBox from './BorderedBox'
4
+ import HorizontalSeparator from './HorizontalSeparator'
5
+ import PullRequestIcon from './icons/PullRequestIcon'
6
+ import styles from './PullRequest.module.css'
7
+ import VerticalSeparator from './VerticalSeparator'
8
+ export default function PullRequest ({ id, title, lastCommit, url }) {
9
+ return (
10
+ <BorderedBox color='green'>
11
+ <div className={styles.header}>
12
+ <PullRequestIcon />
13
+ <span className={styles.id}>#{id}</span>
14
+ <span><a href={url} target='_blank' rel='noreferrer'>{url}</a></span>
15
+ </div>
16
+ <div className={styles.content}>
17
+ <div>
18
+ <span className={styles.label}>PR Title: </span>
19
+ <span className={styles.value}>{title}</span>
20
+ </div>
21
+ </div>
22
+
23
+ <HorizontalSeparator />
24
+ <div>
25
+ <span className={styles.label}>Last commit by: </span>
26
+ <span className={styles.value}>{lastCommit.author}</span>
27
+ <VerticalSeparator />
28
+ <span className={styles.label}>Commit SHA: </span>
29
+ <span className={styles.value}>{lastCommit.sha}</span>
30
+ <VerticalSeparator />
31
+ <span className={styles.label}>Last Update: </span>
32
+ <span className={styles.value}>{lastCommit.date}</span>
33
+ </div>
34
+ </BorderedBox>
35
+ )
36
+ }
@@ -0,0 +1,18 @@
1
+ .container {
2
+ @apply flex flex-col;
3
+ }
4
+ .id {
5
+ @apply text-xl text-main-green font-semibold;
6
+ }
7
+ .header {
8
+ @apply flex items-center gap-x-4 mb-4;
9
+ }
10
+ .label {
11
+ @apply font-thin;
12
+ }
13
+ .value {
14
+ @apply font-semibold;
15
+ }
16
+ .content {
17
+
18
+ }
@@ -6,15 +6,23 @@ import styles from './SearchBar.module.css'
6
6
  import commonStyles from './Common.module.css'
7
7
  export default function SearchBar (props) {
8
8
  const inputRef = useRef()
9
- const { action } = props
10
-
9
+ const { onSubmit, onChange } = props
11
10
  function handleSearch () {
12
- const value = inputRef.current.value
13
- return action(value)
11
+ if (onSubmit) {
12
+ const value = inputRef.current.value
13
+ return onSubmit(value)
14
+ }
15
+ }
16
+
17
+ function handleChange () {
18
+ if (onChange) {
19
+ const value = inputRef.current.value
20
+ return onChange(value)
21
+ }
14
22
  }
15
23
  return (
16
24
  <div className={`${styles.input} ${commonStyles.padded}`}>
17
- <input type='text' placeholder='Search' className='grow' ref={inputRef} />
25
+ <input type='text' placeholder='Search' className='grow' ref={inputRef} onChange={handleChange} />
18
26
  <button onClick={handleSearch}>
19
27
  <FontAwesomeIcon color='white' icon={faSearch} />
20
28
  </button>
@@ -22,7 +22,7 @@ export default function TabbedWindow (props) {
22
22
  <div className={styles['tabs-header']}>
23
23
  {headers.map((header, index) => {
24
24
  return (
25
- <span onClick={() => setSelected(index)} key={index} className={selected === index ? styles['selected-tab'] : ''}>
25
+ <span onClick={() => setSelected(index)} key={index} className={`${styles.tab} ${selected === index ? styles['selected-tab'] : ''}`}>
26
26
  {header}
27
27
  </span>
28
28
  )
@@ -3,8 +3,15 @@
3
3
  }
4
4
 
5
5
  .tabs-header {
6
- @apply flex justify-between text-white uppercase hover:cursor-pointer mb-4 tracking-[.25rem] h-[4rem];
6
+ @apply flex justify-start text-white uppercase hover:cursor-pointer mb-4 tracking-[.25rem] h-[2rem];
7
+ }
8
+ .tab {
9
+ @apply mr-4 min-w-[105px] text-center;
7
10
  }
8
11
  .selected-tab {
9
12
  @apply underline text-main-green underline-offset-8 font-bold;
13
+ }
14
+
15
+ .tabs-content {
16
+ @apply h-screen
10
17
  }
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  export default function ApiIcon () {
2
3
  return (
3
4
  <svg
@@ -1,3 +1,4 @@
1
+ import React from 'react'
1
2
  export default function ApiIconClosed () {
2
3
  return (
3
4
  <svg
@@ -0,0 +1,31 @@
1
+ import * as React from 'react'
2
+
3
+ const PullRequestIcon = () => (
4
+ <svg
5
+ width={40}
6
+ height={40}
7
+ fill='none'
8
+ xmlns='http://www.w3.org/2000/svg'
9
+ >
10
+ <circle cx={9.5} cy={30.5} r={4.5} stroke='#fff' strokeWidth={2} />
11
+ <circle cx={9.5} cy={9.5} r={4.5} stroke='#fff' strokeWidth={2} />
12
+ <path stroke='#fff' strokeWidth={2} d='M9 14v12' />
13
+ <circle cx={30.5} cy={30.5} r={4.5} stroke='#fff' strokeWidth={2} />
14
+ <path
15
+ d='M30.5 26V10.5a1 1 0 0 0-1-1H23'
16
+ stroke='#fff'
17
+ strokeWidth={2}
18
+ strokeLinecap='round'
19
+ strokeLinejoin='round'
20
+ />
21
+ <path
22
+ d='m26 5-4.5 4.5L26 14'
23
+ stroke='#fff'
24
+ strokeWidth={2}
25
+ strokeLinecap='round'
26
+ strokeLinejoin='round'
27
+ />
28
+ </svg>
29
+ )
30
+
31
+ export default PullRequestIcon
@@ -3,7 +3,7 @@ import React from 'react'
3
3
 
4
4
  export default function Layout (props) {
5
5
  return (
6
- <div className='container mx-auto px-4 my-5 flex flex-col gap-10'>
6
+ <div className='container mx-auto px-4 my-5 flex flex-col gap-10 h-screen'>
7
7
  {props.children}
8
8
  </div>
9
9
 
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+ import PullRequest from '../components/PullRequest'
3
+ export default {
4
+ title: 'Platformatic/PullRequest',
5
+ component: PullRequest,
6
+ argTypes: {
7
+ color: { control: 'color' }
8
+ }
9
+ }
10
+
11
+ const Template = (args) => <PullRequest {...args}>Hello Platformatic</PullRequest>
12
+
13
+ export const Standard = Template.bind({})
14
+ Standard.args = {
15
+ id: '88',
16
+ title: 'doc: host => hostname, binded to 0.0.0.0 to be more container friendly',
17
+ url: 'http://example.com',
18
+ lastCommit: {
19
+ sha: 'bgb3ffe3',
20
+ author: 'Foobar',
21
+ date: '2022-10-11'
22
+ }
23
+ }
@@ -0,0 +1,26 @@
1
+ 'use strict'
2
+ import SearchBar from '../components/SearchBar'
3
+ export default {
4
+ title: 'Platformatic/SearchBar',
5
+ component: SearchBar,
6
+ argTypes: {
7
+ color: { control: 'color' }
8
+ }
9
+ }
10
+ const Template = (args) => {
11
+ return (
12
+ <>
13
+ <SearchBar {...args}>Hello Platformatic</SearchBar>
14
+ </>
15
+
16
+ )
17
+ }
18
+ export const Standard = Template.bind({})
19
+ Standard.args = {
20
+ onChange: (value) => {
21
+ console.log('Current search: ' + value)
22
+ },
23
+ onSubmit: (value) => {
24
+ alert('Query value: ' + value)
25
+ }
26
+ }
@@ -1,9 +0,0 @@
1
- 'use strict'
2
- import React from 'react'
3
- import BorderedBox from './BorderedBox'
4
-
5
- export default function Prs () {
6
- return (
7
- <BorderedBox color='green'>PR</BorderedBox>
8
- )
9
- }