Skip to content

Commit 6ced156

Browse files
authored
docs: add icon search input (#6828)
* docs: add icon search input * docs: add affix for search input
1 parent 42608a5 commit 6ced156

File tree

5 files changed

+51
-22
lines changed

5 files changed

+51
-22
lines changed

site/src/layouts/header/SearchBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ref="inputRef"
66
:placeholder="searchPlaceholder"
77
@focus="triggerFocus(true)"
8-
@blue="triggerFocus(false)"
8+
@blur="triggerFocus(false)"
99
></a-input>
1010
</div>
1111
</template>

site/src/theme/static/common.less

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ a {
4646
&:hover &-inner {
4747
overflow-y: auto;
4848
}
49-
50-
> div,
51-
> div > div {
52-
height: 100%;
53-
}
5449
}
5550

5651
.aside-container {

site/src/theme/static/icons.less

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,17 @@ ul.anticons-list {
8686
background: #f5f5f5;
8787
border-radius: 2px;
8888
}
89+
90+
.icons-affix {
91+
display: flex;
92+
justify-content: space-between;
93+
transition: all 0.25s;
94+
}
95+
96+
.icons-affixed {
97+
padding: 12px;
98+
margin: -8px;
99+
border-radius: 6px;
100+
border: 1px solid var(--border-color-base);
101+
background-color: var(--body-background);
102+
}

site/src/theme/template/IconDisplay/CopyableIcon.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const allIcons = AntdIcons;
2222
const kebabCase = function kebabCase(str) {
2323
return str
2424
.split(/(?=[A-Z])/)
25-
.join('-')
26-
.toLowerCase();
25+
.map(s => s.replace(s[0], s[0].toUpperCase()))
26+
.join('');
2727
};
2828
2929
export default defineComponent({

site/src/theme/template/IconDisplay/index.jsx

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ const IconDisplay = defineComponent({
2424
data() {
2525
return {
2626
theme: ThemeType.Outlined,
27+
searchVal: '',
28+
searchBarAffixed: false,
2729
};
2830
},
2931
methods: {
3032
handleChangeTheme(e) {
3133
this.theme = e.target.value;
3234
},
33-
35+
handleAffixChange(affixed) {
36+
this.searchBarAffixed = affixed;
37+
},
3438
renderCategories() {
3539
const { theme } = this;
3640

@@ -42,7 +46,10 @@ const IconDisplay = defineComponent({
4246
category: key,
4347
icons: iconList
4448
.map(iconName => iconName + theme)
45-
.filter(iconName => allIcons[iconName]),
49+
.filter(iconName => {
50+
if (iconName.toLowerCase().includes(this.searchVal.trim().toLowerCase()))
51+
return allIcons[iconName];
52+
}),
4653
};
4754
})
4855
.filter(({ icons }) => !!icons.length)
@@ -62,18 +69,31 @@ const IconDisplay = defineComponent({
6269
return (
6370
<div>
6471
<h3 style="margin: 1.6em 0 .6em;">{this.$t('app.docs.components.icon.pick-theme')}</h3>
65-
<a-radio-group value={this.theme} onChange={this.handleChangeTheme}>
66-
<a-radio-button value={ThemeType.Outlined}>
67-
<Icon component={OutlinedIcon} /> {this.$t('app.docs.components.icon.outlined')}
68-
</a-radio-button>
69-
<a-radio-button value={ThemeType.Filled}>
70-
<Icon component={FilledIcon} /> {this.$t('app.docs.components.icon.filled')}
71-
</a-radio-button>
72-
<a-radio-button value={ThemeType.TwoTone}>
73-
<Icon component={TwoToneIcon} /> {this.$t('app.docs.components.icon.two-tone')}
74-
</a-radio-button>
75-
</a-radio-group>
76-
{this.renderCategories()}
72+
<a-affix offset-top={32} onChange={this.handleAffixChange}>
73+
<div class={this.searchBarAffixed ? 'icons-affix icons-affixed' : 'icons-affix'}>
74+
<a-radio-group value={this.theme} onChange={this.handleChangeTheme}>
75+
<a-radio-button value={ThemeType.Outlined}>
76+
<Icon component={OutlinedIcon} /> {this.$t('app.docs.components.icon.outlined')}
77+
</a-radio-button>
78+
<a-radio-button value={ThemeType.Filled}>
79+
<Icon component={FilledIcon} /> {this.$t('app.docs.components.icon.filled')}
80+
</a-radio-button>
81+
<a-radio-button value={ThemeType.TwoTone}>
82+
<Icon component={TwoToneIcon} /> {this.$t('app.docs.components.icon.two-tone')}
83+
</a-radio-button>
84+
</a-radio-group>
85+
<a-input-search
86+
style="flex: 1 1 0%; margin-inline-start: 16px;"
87+
placeholder={this.$t('app.docs.components.icon.search.placeholder')}
88+
v-model:value={this.searchVal}
89+
/>
90+
</div>
91+
</a-affix>
92+
{this.renderCategories().length === 0 ? (
93+
<a-empty style="padding: 12px 0;" />
94+
) : (
95+
this.renderCategories()
96+
)}
7797
</div>
7898
);
7999
},

0 commit comments

Comments
 (0)