-
Notifications
You must be signed in to change notification settings - Fork 60
Add support for @TopicsVisualStyle
#419
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
Merged
dobromir-hristov
merged 17 commits into
swiftlang:main
from
dobromir-hristov:dhristov/r97716047-support-links-topicsSectionStyle
Sep 20, 2022
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b162696
feat: add support for `@TopicsVisualStyle`
d4fc8cc
refactor: TopicsGrid to user ContentTableSection
1922fe4
refactor: topicLink text
4670a9e
chore: add samplecode
347ac6b
refactor: use slot to provide content
b2e321f
chore: fix import path
25a0857
chore: fix import
f20fad8
fix: merge conflict from renaming Grid to Row
ab3783f
refactor: cleanup the TopicsGrid implementation and merge with Topics…
be4dc16
refactor: cleanup tests
2fce0ff
refactor: do rename the ContentTableSection title to reduce polluting…
d8e47a4
chore: refactor
ccb7ca9
refactor: extract title class to a constant
f18ae15
fix: use `identifier` instead of `reference`
fb0d89c
refactor: rename TopicStyles.js to TopicSectionsStyle.js
928a1d5
fix: bad test
2925a08
chore: fix indentation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!-- | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See https://swift.org/LICENSE.txt for license information | ||
See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
--> | ||
|
||
<template> | ||
<div class="TopicsLinkCardGrid"> | ||
<Row :columns="compactCards ? 3 : 2"> | ||
<Column | ||
v-for="item in items" | ||
:key="item.title" | ||
> | ||
<TopicsLinkCardGridItem :item="item" :compact="compactCards" /> | ||
</Column> | ||
</Row> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Row from 'docc-render/components/ContentNode/Row.vue'; | ||
import Column from 'docc-render/components/ContentNode/Column.vue'; | ||
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle'; | ||
import TopicsLinkCardGridItem from './TopicsLinkCardGridItem.vue'; | ||
export default { | ||
name: 'TopicsLinkCardGrid', | ||
components: { TopicsLinkCardGridItem, Column, Row }, | ||
props: { | ||
items: { | ||
type: Array, | ||
required: true, | ||
}, | ||
topicStyle: { | ||
dobromir-hristov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type: String, | ||
default: TopicSectionsStyle.compactGrid, | ||
validator: v => v === TopicSectionsStyle.compactGrid || v === TopicSectionsStyle.detailedGrid, | ||
}, | ||
}, | ||
computed: { | ||
compactCards: ({ topicStyle }) => topicStyle === TopicSectionsStyle.compactGrid, | ||
}, | ||
}; | ||
</script> |
95 changes: 95 additions & 0 deletions
95
src/components/DocumentationTopic/TopicsLinkCardGridItem.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<!-- | ||
This source file is part of the Swift.org open source project | ||
Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
See https://swift.org/LICENSE.txt for license information | ||
See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
--> | ||
|
||
<template> | ||
<Card | ||
class="reference-card-grid-item" | ||
:url="item.url" | ||
:image="imageReferences.card" | ||
mportiz08 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:title="item.title" | ||
floating-style | ||
:size="cardSize" | ||
:link-text="linkText" | ||
> | ||
<template v-if="!imageReferences.card" #cover="{ classes }"> | ||
<div :class="classes" class="reference-card-grid-item__image"> | ||
<TopicTypeIcon | ||
:type="item.role" | ||
:image-override="references[imageReferences.icon]" | ||
class="reference-card-grid-item__icon" | ||
/> | ||
</div> | ||
</template> | ||
<ContentNode v-if="!compact" :content="item.abstract" /> | ||
</Card> | ||
</template> | ||
|
||
<script> | ||
import Card from 'docc-render/components/Card.vue'; | ||
import TopicTypeIcon from 'docc-render/components/TopicTypeIcon.vue'; | ||
import { TopicRole } from 'docc-render/constants/roles'; | ||
import CardSize from 'docc-render/constants/CardSize'; | ||
export const ROLE_LINK_TEXT = { | ||
mportiz08 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[TopicRole.article]: 'Read article', | ||
[TopicRole.overview]: 'Start tutorial', | ||
[TopicRole.collection]: 'View API collection', | ||
[TopicRole.symbol]: 'View symbol', | ||
[TopicRole.sampleCode]: 'View sample code', | ||
}; | ||
export default { | ||
name: 'TopicsLinkCardGridItem', | ||
components: { | ||
TopicTypeIcon, | ||
Card, | ||
ContentNode: () => import('docc-render/components/ContentNode.vue'), | ||
}, | ||
inject: ['references'], | ||
props: { | ||
item: { | ||
type: Object, | ||
required: true, | ||
}, | ||
compact: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, | ||
computed: { | ||
imageReferences: ({ item }) => (item.images || []).reduce((all, current) => { | ||
// eslint-disable-next-line no-param-reassign | ||
all[current.type] = current.identifier; | ||
return all; | ||
}, { icon: null, card: null }), | ||
linkText: ({ compact, item }) => (compact ? '' : (ROLE_LINK_TEXT[item.role] || 'Learn more')), | ||
cardSize: ({ compact }) => (compact ? undefined : CardSize.large), | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang='scss'> | ||
@import 'docc-render/styles/_core.scss'; | ||
.reference-card-grid-item { | ||
&__image { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 80px; | ||
background-color: var(--color-fill-gray-quaternary); | ||
} | ||
&__icon { | ||
display: flex; | ||
margin: 0; | ||
} | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* This source file is part of the Swift.org open source project | ||
* | ||
* Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
* Licensed under Apache License v2.0 with Runtime Library Exception | ||
* | ||
* See https://swift.org/LICENSE.txt for license information | ||
* See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
/* eslint-disable import/prefer-default-export */ | ||
export const TopicSectionsStyle = { | ||
list: 'list', | ||
compactGrid: 'compactGrid', | ||
detailedGrid: 'detailedGrid', | ||
hidden: 'hidden', | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.