前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >源计划-方舟:存储卡样式标签

源计划-方舟:存储卡样式标签

作者头像
Akilar
发布2023-01-30 15:08:22
6450
发布2023-01-30 15:08:22
举报

点击查看更新记录

更新记录

2023-01-04:内测版

  1. 实现侧栏标签卡片存储卡样式
  2. 实现标签页面卡片存储卡样式
  3. 标签侧栏卡片新增跳转至标签页面按钮。

点击查看参考教程

|参考了UI风格和配色样式|【G端】不想再做蓝蓝科技风了 黄/黑/橙配色| |fontawesome图标文档|fontawesome| |Flex布局参数解释|Flex 布局教程:语法篇 - 阮一峰的网络日志| |Transition属性实现平滑过渡动画|CSS3实现伪类hover离开时平滑过渡效果示例| |CSS伪类实现三角形绘制|纯CSS 实现绘制各种三角形(各种角度) - saucxs - 博客园| |使用clip-path实现多边形剪裁。|不可思议的CSS之clip-path| |站内教程:iconfont引入教程|Hexo引入阿里矢量图标库| |参考空梦的方案实现长文本轮回滚动|空梦——纯 CSS 实现超长文本轮回滚动| |参考Eurkon的方案实现标签数量角标|Eurkon—Butterfly 标签云增加文章数上下标|

预览效果

点击查看预览效果

标签页预览
标签页预览
侧栏标签预览
侧栏标签预览

魔改步骤

新建[Blogroot]\themes\butterfly\scripts\helpers\cyber_tag.js,这个的功能就是按照hexo给的tag数据集编译出我们需要的tag单元。

hexo.extend.helper.register('cyberTags', function (options = {}) {
  const env = this
  let source = options.source
  const limit = options.limit

  let result = ''
  if (limit > 0) {
    source = source.limit(limit)
  }

  source.forEach(tag => {

    result += `<a class="cyber-tags-box" href="${env.url_for(tag.path)}"><span class="cyber-tags-name-box"><b class="cyber-tags-name">${tag.name}</b></span><span class="cyber-tags-length">${tag.length}</span></a>`
  })
  return result
})

新建[Blogroot]\themes\butterfly\source\css\_layour\cyber_tags.styl

//基本样式,保证侧栏和标签页风格一致
#aside-content .card-tags,
#page .tag-cloud-list
  .card-tag-cloud
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    a.cyber-tags-box
      position: relative
      z-index: 1
      background: transparent
      display: flex;
      align-items: center;
      flex-direction: row;
      justify-content: space-between;
      color: white;
      font-family: 'UnidreamLED','TaikoMagic';
      border-radius: 3px;
      &::before
        content: ""
        z-index: 0
        position: absolute;
        top: 0;
        left: 0;
        display: block;
        background: #172433;


        border-radius: 3px;
      &::after
        content: "";
        z-index: -1;
        position: absolute;
        display: block;
        background: transparent;
        border-color: #fd4000;
        border-style: dotted solid solid none;
        border-radius: 3px;

      span.cyber-tags-name-box
        overflow hidden
        z-index: 1
        margin: 0 3px 0 0   
        b.cyber-tags-name
          float left
          white-space nowrap
          animation text-roll 4s cubic-bezier(.6, 0, .5, 1) alternate infinite
          min-width 100%
      span.cyber-tags-length
        z-index: 1
        position: relative;
        &::after
          content: "";
          position: absolute;
          box-shadow: 0px 0px 0px 0.5px inset #232323;
          
//针对侧栏比例进行调整。整体偏小
#aside-content .card-tags
  .card-tag-cloud
    a.cyber-tags-box
      width: 80px;
      height: 60px;
      margin: 0 4px 4px 0;
      padding: 0 10px 0 5px;
      font-size: 12px;
      &::before
        width: 80px;
        height: 60px;
        clip-path: polygon(0px 6px,40px 6px,45px 0,100% 0,100% calc(50% - 12px),calc(100% - 5px) calc(50% - 10px),calc(100% - 5px) calc(50% + 10px),100% calc(50% + 12px),100% 100%,10px 100%,0 calc(100% - 10px))
        box-shadow: 0px 0px 0px 3px inset #4a4f56;
      &::after
        top: 4px;
        left: 2px;
        width: 72px;
        height: 41px;
        border-width: 3px 5px 10px 0px;

      span.cyber-tags-name-box
        width 4em
        height 12px
        
        b.cyber-tags-name
          line-height: 12px;
      span.cyber-tags-length
        line-height: 12px;
        &::after
          width: 60px;
          height: 3px;
          right: 0px;
          bottom: -10px;
          background: linear-gradient(to right,#fd4000 20px,#fd4000,white 21px,white)         
    a.cyber-tags-button
      background: black;
      width: 200px;
      height: 30px;
      display: flex;
      font-size: 12px;
      font-family: 'UnidreamLED','TaikoMagic';
      text-align: center;
      box-shadow: 0px 0px 0px 3px inset #4a4f56;
      border-radius: 3px;
      justify-content: center;
      align-items: center;
//针对分类页面进行调整
#page .tag-cloud-list
  .card-tag-cloud
    a.cyber-tags-box
      width: 100px;
      height: 70px;
      margin: 0 4px 4px 4px
      padding: 0 10px 0 5px;
      font-size: 12px;
      &::before
        width: 100px;
        height: 70px;
        clip-path: polygon(0px 6px,40px 6px,45px 0,100% 0,100% calc(50% - 12px),calc(100% - 5px) calc(50% - 10px),calc(100% - 5px) calc(50% + 10px),100% calc(50% + 12px),100% 100%,10px 100%,0 calc(100% - 10px))
        box-shadow: 0px 0px 0px 3px inset #4a4f56;
      &::after
        top: 4px;
        left: 2px;
        width: 92px;
        height: 50px;
        border-width: 3px 5px 10px 0px;

      span.cyber-tags-name-box
        width 6em
        height 14px       
        b.cyber-tags-name
          line-height: 12px;
      span.cyber-tags-length
        line-height: 12px;
        &::after
          width: 80px;
          height: 3px;
          right: 0px;
          bottom: -12px;
          background: linear-gradient(to right,#fd4000 30px,#fd4000,white 31px,white)         

//感谢空梦提供的过长文本轮回滚动方案
//https://kmar.top/posts/9db1c87c/
@keyframes text-roll
  from
    margin 0
  to
    margin-left 100%
    transform translateX(-100%)

修改[Blogroot]\themes\butterfly\layout\includes\page\tags.pug,

  .tag-cloud-list.is-center
+   if theme.aside.card_tags.cyber
+     .card-tag-cloud!= cyberTags({source: site.tags, unit: 'em'})
+   else if theme.aside.card_tags.color
-   if theme.aside.card_tags.color
      !=cloudTags({source: site.tags, minfontsize: 1.2, maxfontsize: 2.1, limit: 0, unit: 'em'})

修改[Blogroot]\themes\butterfly\layout\includes\widget\card_tags.pug,

  if theme.aside.card_tags.enable
    if site.tags.length
      .card-widget.card-tags
        .item-headline
          i.fas.fa-tags
          span= _p('aside.card_tags')

        - let tagLimit = theme.aside.card_tags.limit === 0 ? 0 : theme.aside.card_tags.limit || 40
+       if theme.aside.card_tags.cyber
+         .card-tag-cloud!= cyberTags({source: site.tags, limit: tagLimit, unit: 'em'})
+           a.cyber-tags-button(href=`/` + config.tag_dir + `/`)
+             span.cyber-tags-more= _p('aside.card_tags_more')
+       else if theme.aside.card_tags.color
-       if theme.aside.card_tags.color
          .card-tag-cloud!= cloudTags({source: site.tags, minfontsize: 1.15, maxfontsize: 1.45, limit: tagLimit, unit: 'em'})
        else
          .card-tag-cloud!= tagcloud({min_font: 1.1, max_font: 1.5, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'})

到主题配置项[Blogroot]\_config.butterfly.yml,找到侧栏卡片的配置项,新增配置项。为了侧栏显示效果,建议把limit配置项设置为18。:

  card_tags:
    enable: true
    limit: 18 # if set 0 will show all
+   cyber: true
    color: false
    sort_order: # Don't modify the setting unless you know how it works
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2023-01-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 预览效果
  • 魔改步骤
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档