-
-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
6,149 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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,54 @@ | ||
import React from 'react' | ||
import Speaker from '@/components/Speaker' | ||
import { OALDResult, OALDResultLex, OALDResultRelated } from './engine' | ||
|
||
export default class DictOALD extends React.PureComponent<{ result: OALDResult }> { | ||
handleEntryClick = (e: React.MouseEvent<HTMLElement>) => { | ||
const target = e.nativeEvent.target as HTMLSpanElement | ||
if (target.classList && target.classList.contains('heading')) { | ||
(target.parentElement as HTMLDivElement).classList.toggle('is-active') | ||
} | ||
} | ||
|
||
renderLex (result: OALDResultLex) { | ||
return result.items.map(entry => ( | ||
<section key={entry.title} className='dictOALD-Entry' onClick={this.handleEntryClick}> | ||
<header className='dictOALD-Header'> | ||
<div className='webtop-g' dangerouslySetInnerHTML={{ __html: entry.title }} /> | ||
{entry.prons.length > 0 && | ||
<div className='pron-gs ei-g'> | ||
{entry.prons.map(p => ( | ||
<React.Fragment key={p.phsym}> | ||
<span className='pron-g' dangerouslySetInnerHTML={{ __html: p.phsym }} /> | ||
<Speaker src={p.pron} /> | ||
</React.Fragment> | ||
))} | ||
</div> | ||
} | ||
</header> | ||
<span className='h-g' dangerouslySetInnerHTML={{ __html: entry.defs }} /> | ||
</section> | ||
)) | ||
} | ||
|
||
renderRelated (result: OALDResultRelated) { | ||
return ( | ||
<> | ||
<p>Did you mean:</p> | ||
<ul className='dictOALD-Related' dangerouslySetInnerHTML={{ __html: result.list }} /> | ||
</> | ||
) | ||
} | ||
|
||
render () { | ||
const { result } = this.props | ||
switch (result.type) { | ||
case 'lex': | ||
return this.renderLex(result) | ||
case 'related': | ||
return this.renderRelated(result) | ||
default: | ||
return null | ||
} | ||
} | ||
} |
This file contains 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,14 @@ | ||
{ | ||
"name": { | ||
"en": "OALD", | ||
"zh_CN": "OALD", | ||
"zh_TW": "OALD" | ||
}, | ||
"options": { | ||
"related": { | ||
"en": "Show related results", | ||
"zh_CN": "失败时显示备选", | ||
"zh_TW": "失敗時顯示備選" | ||
} | ||
} | ||
} |
Oops, something went wrong.