GoogleTranslate icon indicating copy to clipboard operation
GoogleTranslate copied to clipboard

自动调整翻译输入框中的字号

Open mantou132 opened this issue 7 years ago • 3 comments

类似谷歌翻译的 webapp,字数或者行数过多时调整字号

mantou132 avatar Sep 05 '18 23:09 mantou132

这是个好主意,不过不知道是否会影响界面美观

u3u avatar Sep 06 '18 01:09 u3u

多行时才会调整字号,就算在当前样式下问题也不大。

我在实现时遇到两个问题:

  1. vue-emotion 怎么响应式的修改样式
  2. 跟 autosize 冲突,监听

不过当

如果今后需要显示更多的翻译结果信息,其他内容的字号需要相应的调整。

这个

mantou132 avatar Sep 06 '18 13:09 mantou132

vue-emotion 怎么响应式的修改样式

可以通过传递 props 的方式动态修改

const H1 = styled.h1`
  font-size: ${(props) => props.size}px;
  color: ${(props) => props.color};
  transition: all 0.3s ease;
`;
@Component
export default class Test extends Vue {
  size = 12;
  color = 'red';

  created() {
    setTimeout(() => {
      this.size = 16;
      this.color = 'green';
    }, 500);
  }

  render() {
    const { size, color } = this;
    return (
      <H1 size={size} color={color}>
        Title
      </H1>
    );
  }
}

跟 autosize 冲突

这个应该可以用 autosize.update(elements) 来重新更新高度

不应该在单词内换行

这个需要把 word-breakbreak-all 修改成 keep-all 🌚

https://github.com/MoeFE/GoogleTranslate/blob/15bdc95ebc12d7b1c8571346d002fffe8f46a81f/src/renderer/components/TextBox.tsx#L25

u3u avatar Sep 07 '18 03:09 u3u